Блог пользователя KunalSin9h

Автор KunalSin9h, история, 15 месяцев назад, По-английски

While implementing Binary Search, we may face few problems, they are:

• What is the value of lower bound?

• What is the value of upper bound?

• How do I calculate my mid value?

• What condition should I write in my while loop?

• When my predicate is true, should I assign my mid to lower or upper bound?

• Whats my final answer, value of lower or upper bound?

Inspired from @Benq solutions, I wrote down all you need to know about correctly implementing binary search and its sub-classes (First True and last True), which works every time.

Read full Paper: Here on Academia.edu

  • Проголосовать: нравится
  • -25
  • Проголосовать: не нравится