The Binary Search Algorithm (+ Python Code Solution)

preview_player
Показать описание
FAANG Coding Interviews / Data Structures and Algorithms / Leetcode
Рекомендации по теме
Комментарии
Автор

Master Data Structures & Algorithms For FREE at AlgoMap.io!

GregHogg
Автор

In most other languages, its better to do "left + (right - left) // 2", which is equal to "(right + left) // 2", except it takes away the chance of integer overflow. In Python it doesn't matter since numbers can theoretically be as large as needed.

big-anvil
Автор

Remember that the list MUST be sorted, otherwise it won't work

greensalad_
Автор

This can also be done recursively, but then the space complexity increases.

mohammedadel
Автор

Nice video. Forgot one critical thing, it should be sorted first to be able to perform this operation.

pangzlab
Автор

Yeah but you’d have to make sure it’s a sorted array first right? So you’d do a sorting algorithm?

AlexYSun
Автор

Why is M under -1 when -1 + 0 // 2 = -0.5 always rounds down to 0, M should be = to 0 ?

muizHD
Автор

👍🏼 what's the step over this in terms of complexity?

observer
Автор

the problem is when u dont have a target

gomitos
Автор

please make another one, but the list is not sorted. Thank you

putuadibrata
Автор

Useless cuz you could have random numbers

alexkonrad
visit shbcf.ru