Why Binary Search is O(log n)

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

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

GregHogg
Автор

It's quite important to mention that this only work with a sorted array.

thibauldnuyten
Автор

Thank you Greg for short clips that not only helps to revise but are also handy at times!

SiddhantSancheti-kkzd
Автор

Love these shorts to brush up my DSA topics... Keep making!

Aman-xoyx
Автор

bcos when you count up 2, 4, 8… it’s 2 to the power of n and when you count down by dividing, of course it’s log2(8), log2(4), its logN.

radiosparrow
Автор

Technically log base 2 of n but we ommit that from time notation

Matt-skhi
Автор

God I love binary search. I know, I know quicksort under the hood for sort, but come on, this is fantastic.

askholia
Автор

Thanks for doing this video! Do you have a video talks about dynamic programming, DFS, BFS, minimum spinning tree, minimum path?

kapokwok
Автор

Can you do a big O calculation for Ologn?

__--__--__--__--
Автор

I was wondering abt this

Given an unsorted array (assume its quite big), and we want to check if the array contains a specific element if we want to use binary search we would need to sort it first and the most efficient sorting algorithm so far (afaik) is O(n log n, like quicksort) and then we use binary search, but would a linear search with O(n) would be better since its linear runtime and also didnt modify the array?

ryaninkachandra
Автор

What if its not sorted whats the best approach

Etk
Автор

Hello did you made a video about what is the best sorting algorithm ?

sharokhkeshawarz
Автор

As if you will get a sorted array. And If you do receive a sorted array, you can kiss your performance goodbye even before you start.

tazanteflight
Автор

You should include the fact your y-axis has 0 on the right instead of the left like a normal graph would

airkami
Автор

Doesn't this only work on a sorted array? Otherwise your value might be on the side you remove?

peettims
Автор

O(log n) is whenever search get devided by halve

joeblack
Автор

hey, nice video as always, can you answer why is merge sort n*logn

badreddineboukheit
Автор

Whats the log of 2^10, it's 10log(2)

thebeastsclips
Автор

Thank you for the video but you didn’t explain why its logN

vetirs
Автор

You missed the most important part which is it has to be sorted 😅

TRXTRZ