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)?
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?
another day, another person's semester you just saved
Boom! Awesome.
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
CS UG student here, you are precise and to the point which makes you different from rest of the creators
great to hear!
Best video on binary search I've found, straight to the point with well made animations. Thanks a lot Michael!
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.
Thanks bro! Keep going 💪🏼
Thank you for using a black background and white text. All of your older sorting algorithm videos were really helpful.
you're welcome, thanks for watching!
u r singlehandedly making algorithms easy for people keep it upppppp
damn, this is amazing and exactly what i wanted as a python beginner currently. thanks Michael
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!
such a great explanation, I love your calmness
thank you!
Ur the goat bro I just watch ur vids 1 hr before the exam and covered the entire 5 months syllabus ,🔥🔥
Cool stuff Michael! Keep up the great work!
Amazing explanation. Thank you!
reviewing for a data structures quiz rn, this was exactly what i was looking for! 💪very clear and helpful explanation :3
Oh this makes it so much easier i was watching the visualisation but i just get confused lol since i am not very perceptive thank you this helps a lot
Please please please keep making videos, I watch your videos everyday, you make my day, thank you
More coming! 4 weddings in October stalled my progress. Thank you for watching!
@@MichaelSambol 4 wives? As expected of Mr. Sambol.
Nicely explained!
thank you! I appreciate you watching.
Him: “quick sort=pivot”
Me: “WHILE HE HID IN RADIO WE PIVOTED TO VIDEO 🗣️💥”
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)?
Might be helpful to watch the whole playlist on analyzing algorithms: ruclips.net/p/PL9xmBV_5YoZMxejjIyFHWa-4nKg6sdoIv
Great Explaination! Could you make a video on Linear Search is well?
:)
Bro is actually a godsend
i like your explanation:) keep it up
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
0:35 generally it will be rounding down since int always kind off round down by default in more languages
great vid man keep it up
amazing video keep it up!
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?
yep. see code here: github.com/msambol/youtube/blob/master/search/binary_search.py
@@MichaelSambol Great! thanks a lot
thanks bro, iam understand now
you are a legend
thank you so much !
THANK YOU
bro should be known by more people
Curious if it would behoove the algorithm to check if either left, right, or mid is the answer
can you make one on linear searches
thank you
Whats the purpose of returning specifically -1 if the target value is not found? Why not simply state that the target wasnt found?
Can do either :)
lifesaver
These search routines are canned so you can just grab them and use them
nice explanation but how do i know the time complexity?
do i calculate or something? hehe
Take a look here, this should help: ruclips.net/p/PL9xmBV_5YoZMxejjIyFHWa-4nKg6sdoIv
thank you Sir !! @@MichaelSambol
👏👏
niceeee
Why not return array[mid], why return mid I don't understand
The code returns the index/location of the element you're searching for: github.com/msambol/youtube/blob/master/search/binary_search.py.
if you return array[mid], you would return the number you are looking for, because mid is the index of the wanted number.
what if the number 29, how will it work
Try it here :) github.com/msambol/dsa/blob/master/search/binary_search.py
why do we return -1?
returning -1 if key is not in the array. otherwise return the key: github.com/msambol/dsa/blob/master/search/binary_search.py#L9
There are 14 numbers in this LIST.. so Average should be (0,14)=7
It's by index in the array... so 0 and 13. See code here: github.com/msambol/dsa/blob/master/search/binary_search.py
@@MichaelSambol Thank you!!! =)
𝓅𝓇𝑜𝓂𝑜𝓈𝓂 ✔️