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 Жыл бұрын
another day, another person's semester you just saved
@MichaelSambol Жыл бұрын
Boom! Awesome.
@masterhimanshu846725 күн бұрын
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-bq6mr9ek4r7 ай бұрын
Best video on binary search I've found, straight to the point with well made animations. Thanks a lot Michael!
@amitos16469 ай бұрын
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.
@MichaelSambol9 ай бұрын
Thanks bro! Keep going 💪🏼
@nalskipper7447 Жыл бұрын
Thank you for using a black background and white text. All of your older sorting algorithm videos were really helpful.
@MichaelSambol Жыл бұрын
you're welcome, thanks for watching!
@harshvardhansingh55078 ай бұрын
CS UG student here, you are precise and to the point which makes you different from rest of the creators
@MichaelSambol8 ай бұрын
great to hear!
@hojongyu8243 Жыл бұрын
Amazing explanation. Thank you!
@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 Жыл бұрын
such a great explanation, I love your calmness
@MichaelSambol Жыл бұрын
thank you!
@alitia7 Жыл бұрын
Cool stuff Michael! Keep up the great work!
@sudhirms65076 ай бұрын
Ur the goat bro I just watch ur vids 1 hr before the exam and covered the entire 5 months syllabus ,🔥🔥
@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 Жыл бұрын
Great Explaination! Could you make a video on Linear Search is well? :)
@sweetphilly2 Жыл бұрын
Curious if it would behoove the algorithm to check if either left, right, or mid is the answer
@ziyad7780 Жыл бұрын
i like your explanation:) keep it up
@anirudh4946 Жыл бұрын
Nicely explained!
@MichaelSambol Жыл бұрын
thank you! I appreciate you watching.
@jakubrembiasz894213 күн бұрын
amazing video keep it up!
@vraimoi7 күн бұрын
great vid man keep it up
@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 Жыл бұрын
yep. see code here: github.com/msambol/youtube/blob/master/search/binary_search.py
@techytech07 Жыл бұрын
@@MichaelSambol Great! thanks a lot
@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Ай бұрын
Might be helpful to watch the whole playlist on analyzing algorithms: kzfaq.info/sun/PL9xmBV_5YoZMxejjIyFHWa-4nKg6sdoIv
@Neb_Explains Жыл бұрын
0:35 generally it will be rounding down since int always kind off round down by default in more languages
@kafychannel Жыл бұрын
thank you so much !
@okok-sc2cx Жыл бұрын
Please please please keep making videos, I watch your videos everyday, you make my day, thank you
@MichaelSambol Жыл бұрын
More coming! 4 weddings in October stalled my progress. Thank you for watching!
@ZandalfBunt Жыл бұрын
@@MichaelSambol 4 wives? As expected of Mr. Sambol.
@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 Жыл бұрын
you are a legend
@LexStilinskiАй бұрын
Him: “quick sort=pivot” Me: “WHILE HE HID IN RADIO WE PIVOTED TO VIDEO 🗣️💥”
@nerfornada-8 ай бұрын
THANK YOU
@bossmusa90759 ай бұрын
thank you
@head-lag Жыл бұрын
niceeee
@eliyoung9406Ай бұрын
Bro is actually a godsend
@folklore6270 Жыл бұрын
lifesaver
@VitorRaimundo1710 Жыл бұрын
👏👏
@obama782811 күн бұрын
can you make one on linear searches
@MrBurn6665 ай бұрын
Whats the purpose of returning specifically -1 if the target value is not found? Why not simply state that the target wasnt found?
@MichaelSambol5 ай бұрын
Can do either :)
@doodle_mo_ka4336 Жыл бұрын
bro should be known by more people
@stutipande254210 ай бұрын
why do we return -1?
@MichaelSambol10 ай бұрын
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Ай бұрын
nice explanation but how do i know the time complexity?
@rain_yyАй бұрын
do i calculate or something? hehe
@MichaelSambolАй бұрын
Take a look here, this should help: kzfaq.info/sun/PL9xmBV_5YoZMxejjIyFHWa-4nKg6sdoIv
@rain_yyАй бұрын
thank you Sir !! @@MichaelSambol
@jwinwithin512426 күн бұрын
what if the number 29, how will it work
@MichaelSambol26 күн бұрын
Try it here :) github.com/msambol/dsa/blob/master/search/binary_search.py
@zea7452 Жыл бұрын
Why not return array[mid], why return mid I don't understand
@MichaelSambol Жыл бұрын
The code returns the index/location of the element you're searching for: github.com/msambol/youtube/blob/master/search/binary_search.py.
@maxheinwal50843 ай бұрын
if you return array[mid], you would return the number you are looking for, because mid is the index of the wanted number.
@ZFlyingVLover Жыл бұрын
These search routines are canned so you can just grab them and use them
@kobey304411 ай бұрын
There are 14 numbers in this LIST.. so Average should be (0,14)=7
@MichaelSambol11 ай бұрын
It's by index in the array... so 0 and 13. See code here: github.com/msambol/dsa/blob/master/search/binary_search.py