Binary search in 4 minutes

  Рет қаралды 99,336

Michael Sambol

Michael Sambol

Жыл бұрын

Binary search in 4 minutes.
Code: github.com/msambol/dsa/blob/m...
Sources:
1. Introduction To Algorithms, Third Edition (CLRS) [www.amazon.com/Introduction-A...]
2. en.wikipedia.org/wiki/Binary_...
LinkedIn: / michael-sambol

Пікірлер: 64
@theatticbywik8238
@theatticbywik8238 Жыл бұрын
another day, another person's semester you just saved
@MichaelSambol
@MichaelSambol Жыл бұрын
Boom! Awesome.
@masterhimanshu8467
@masterhimanshu8467 25 күн бұрын
Lmao I am having my practical today and I am doing this now... That too without laptop... 😂 And I have to do it in C language lol
@user-bq6mr9ek4r
@user-bq6mr9ek4r 7 ай бұрын
Best video on binary search I've found, straight to the point with well made animations. Thanks a lot Michael!
@amitos1646
@amitos1646 9 ай бұрын
Damn. I am commenting a bit late but man it's people like you who help me keep on coding and not giving up. Thank you! Amazing content.
@MichaelSambol
@MichaelSambol 9 ай бұрын
Thanks bro! Keep going 💪🏼
@nalskipper7447
@nalskipper7447 Жыл бұрын
Thank you for using a black background and white text. All of your older sorting algorithm videos were really helpful.
@MichaelSambol
@MichaelSambol Жыл бұрын
you're welcome, thanks for watching!
@harshvardhansingh5507
@harshvardhansingh5507 8 ай бұрын
CS UG student here, you are precise and to the point which makes you different from rest of the creators
@MichaelSambol
@MichaelSambol 8 ай бұрын
great to hear!
@hojongyu8243
@hojongyu8243 Жыл бұрын
Amazing explanation. Thank you!
@theanamex9969
@theanamex9969 Жыл бұрын
Your code is so simple and easily understandable, it helped a lot. My professor had 3 slides on it, very yuck. Thank you so much!
@glenn7422
@glenn7422 Жыл бұрын
such a great explanation, I love your calmness
@MichaelSambol
@MichaelSambol Жыл бұрын
thank you!
@alitia7
@alitia7 Жыл бұрын
Cool stuff Michael! Keep up the great work!
@sudhirms6507
@sudhirms6507 6 ай бұрын
Ur the goat bro I just watch ur vids 1 hr before the exam and covered the entire 5 months syllabus ,🔥🔥
@Czarcasm.
@Czarcasm. 25 күн бұрын
reviewing for a data structures quiz rn, this was exactly what i was looking for! 💪very clear and helpful explanation :3
@t_ahmad
@t_ahmad Жыл бұрын
Great Explaination! Could you make a video on Linear Search is well? :)
@sweetphilly2
@sweetphilly2 Жыл бұрын
Curious if it would behoove the algorithm to check if either left, right, or mid is the answer
@ziyad7780
@ziyad7780 Жыл бұрын
i like your explanation:) keep it up
@anirudh4946
@anirudh4946 Жыл бұрын
Nicely explained!
@MichaelSambol
@MichaelSambol Жыл бұрын
thank you! I appreciate you watching.
@jakubrembiasz8942
@jakubrembiasz8942 13 күн бұрын
amazing video keep it up!
@vraimoi
@vraimoi 7 күн бұрын
great vid man keep it up
@techytech07
@techytech07 Жыл бұрын
Just a quick question, after finding the average of index, if that mid position happens to land on the target index, does the search stop and the target is found?
@MichaelSambol
@MichaelSambol Жыл бұрын
yep. see code here: github.com/msambol/youtube/blob/master/search/binary_search.py
@techytech07
@techytech07 Жыл бұрын
@@MichaelSambol Great! thanks a lot
@user-mt4wg8qj2k
@user-mt4wg8qj2k Ай бұрын
I watched previously the video where you explain the Big-O Notation, in it you showed ant the end that in a "IF -> ELSEIF -> ELSE" the time complexity would be O(n^2). At 2:47 there was an "IF -> ELSEIF -> ELSE" why is the time complexity in this case O(log n) and not O(n^2)?
@MichaelSambol
@MichaelSambol Ай бұрын
Might be helpful to watch the whole playlist on analyzing algorithms: kzfaq.info/sun/PL9xmBV_5YoZMxejjIyFHWa-4nKg6sdoIv
@Neb_Explains
@Neb_Explains Жыл бұрын
0:35 generally it will be rounding down since int always kind off round down by default in more languages
@kafychannel
@kafychannel Жыл бұрын
thank you so much !
@okok-sc2cx
@okok-sc2cx Жыл бұрын
Please please please keep making videos, I watch your videos everyday, you make my day, thank you
@MichaelSambol
@MichaelSambol Жыл бұрын
More coming! 4 weddings in October stalled my progress. Thank you for watching!
@ZandalfBunt
@ZandalfBunt Жыл бұрын
@@MichaelSambol 4 wives? As expected of Mr. Sambol.
@Jkauppa
@Jkauppa Жыл бұрын
hey, try median bucket sort, its 2n log n, ie, first linear median search O(n) then split the elements to two buckets, repeat for sub-buckets
@magma6554
@magma6554 Жыл бұрын
you are a legend
@LexStilinski
@LexStilinski Ай бұрын
Him: “quick sort=pivot” Me: “WHILE HE HID IN RADIO WE PIVOTED TO VIDEO 🗣️💥”
@nerfornada-
@nerfornada- 8 ай бұрын
THANK YOU
@bossmusa9075
@bossmusa9075 9 ай бұрын
thank you
@head-lag
@head-lag Жыл бұрын
niceeee
@eliyoung9406
@eliyoung9406 Ай бұрын
Bro is actually a godsend
@folklore6270
@folklore6270 Жыл бұрын
lifesaver
@VitorRaimundo1710
@VitorRaimundo1710 Жыл бұрын
👏👏
@obama7828
@obama7828 11 күн бұрын
can you make one on linear searches
@MrBurn666
@MrBurn666 5 ай бұрын
Whats the purpose of returning specifically -1 if the target value is not found? Why not simply state that the target wasnt found?
@MichaelSambol
@MichaelSambol 5 ай бұрын
Can do either :)
@doodle_mo_ka4336
@doodle_mo_ka4336 Жыл бұрын
bro should be known by more people
@stutipande2542
@stutipande2542 10 ай бұрын
why do we return -1?
@MichaelSambol
@MichaelSambol 10 ай бұрын
returning -1 if key is not in the array. otherwise return the key: github.com/msambol/dsa/blob/master/search/binary_search.py#L9
@rain_yy
@rain_yy Ай бұрын
nice explanation but how do i know the time complexity?
@rain_yy
@rain_yy Ай бұрын
do i calculate or something? hehe
@MichaelSambol
@MichaelSambol Ай бұрын
Take a look here, this should help: kzfaq.info/sun/PL9xmBV_5YoZMxejjIyFHWa-4nKg6sdoIv
@rain_yy
@rain_yy Ай бұрын
thank you Sir !! @@MichaelSambol
@jwinwithin5124
@jwinwithin5124 26 күн бұрын
what if the number 29, how will it work
@MichaelSambol
@MichaelSambol 26 күн бұрын
Try it here :) github.com/msambol/dsa/blob/master/search/binary_search.py
@zea7452
@zea7452 Жыл бұрын
Why not return array[mid], why return mid I don't understand
@MichaelSambol
@MichaelSambol Жыл бұрын
The code returns the index/location of the element you're searching for: github.com/msambol/youtube/blob/master/search/binary_search.py.
@maxheinwal5084
@maxheinwal5084 3 ай бұрын
if you return array[mid], you would return the number you are looking for, because mid is the index of the wanted number.
@ZFlyingVLover
@ZFlyingVLover Жыл бұрын
These search routines are canned so you can just grab them and use them
@kobey3044
@kobey3044 11 ай бұрын
There are 14 numbers in this LIST.. so Average should be (0,14)=7
@MichaelSambol
@MichaelSambol 11 ай бұрын
It's by index in the array... so 0 and 13. See code here: github.com/msambol/dsa/blob/master/search/binary_search.py
@kobey3044
@kobey3044 11 ай бұрын
@@MichaelSambol Thank you!!! =)
@luislambert6955
@luislambert6955 Жыл бұрын
𝓅𝓇𝑜𝓂𝑜𝓈𝓂 ✔️
Breadth-first search in 4 minutes
3:59
Michael Sambol
Рет қаралды 235 М.
Binary Search Animated
7:00
Dreams of Code
Рет қаралды 21 М.
[柴犬ASMR]曼玉Manyu&小白Bai 毛发护理Spa asmr
01:00
是曼玉不是鳗鱼
Рет қаралды 47 МЛН
ONE MORE SUBSCRIBER FOR 6 MILLION!
00:38
Horror Skunx
Рет қаралды 13 МЛН
Do you have a friend like this? 🤣#shorts
00:12
dednahype
Рет қаралды 44 МЛН
2D water magic
10:21
Steve Mould
Рет қаралды 373 М.
Sommes de Riemann (3).
5:56
MATH ISLAND
Рет қаралды 34
Learn Binary Search in 10 minutes 🪓
10:04
Bro Code
Рет қаралды 98 М.
Counting Sort - Made EASY!
2:13
Deltaverse
Рет қаралды 69
Binary Search Algorithm - Computerphile
18:34
Computerphile
Рет қаралды 155 М.
AVL trees in 9 minutes - Insertions
9:00
Michael Sambol
Рет қаралды 33 М.
Binary Search - A Different Perspective | Python Algorithms
8:56
How Binary Search Makes Computers Much, Much Faster
6:51
Tom Scott
Рет қаралды 1,4 МЛН