LeetCode Binary Search Explained - Java Solution

preview_player
Показать описание


Preparing For Your Coding Interviews? Use These Resources
————————————————————

Other Social Media
----------------------------------------------

Show Support
------------------------------------------------------------------------------

#coding #programming #softwareengineering
Рекомендации по теме
Комментарии
Автор

Hey, first of all thanks for the series. Secondly I just had a quick math question, wouldnt (left + right) / 2 suffice? why did you say "just to be accurate" with the equation you used. Maybe i'm just too tired and its going over my head at the moment lol

claytonmatulich
Автор

Was this video recorded in UB library? :)

karthiklv
Автор

can anyone tell me why he use (right-left)/2 instead of right to calculate mid point?

lakhbawa
Автор

isnt this infinite loop if key not in array?

prerakchoksi
Автор

so what happens if the length of the array is even? if the right most index is 5, and the beginning index is 0, (0+5)/2 is a fraction. How do you take the index of a fraction?

toastyshrimp