Probably my favourite algorithm. Any time I know a dataset is sorted, I just want to employ this.
@troyke4 жыл бұрын
Thank you Doug! As always, a very clear explanation, with visuals to help support your points!
@omaroats6 жыл бұрын
Perfect. This was well explained and easy to follow. Thank you Doug ❤︎
@candicehwt63754 жыл бұрын
every time he asked a question, I was like no please don't pick me to answer, I don't know
@ojalafsenior4757 Жыл бұрын
Very well elaborated Doug
@codeklaudia96965 ай бұрын
Thank you for the video :) Sometimes it is hard to find the Middle. In Python 2, all sorts of divisions return an int. In Python 3 we need to use the // operator
@mandaleswaranthasarathakum31305 жыл бұрын
Thanks man helped with my computing test on search and sorts
@hugger-bd5ij4 жыл бұрын
Matthew Mcclintic why
@vk-hm6te4 жыл бұрын
@Matthew Mcclintic why
@MR0IAM0WATCHING0U4 жыл бұрын
@Matthew Mcclintic why
@matthewmcclintic54884 жыл бұрын
Sorry, I don’t know why I said that. I was trying to be funny next to my friend, as you can see with other comments, but it was stupid.
@matthewmcclintic54884 жыл бұрын
I thought the video was very helpful too and it was not my place to say something like that.
@TheInvestmentCircle5 жыл бұрын
I wish there were coding examples in these videos :[
@Dinopeach4 жыл бұрын
check big-o.io
@exnihilonihilfit63162 жыл бұрын
Ever heard of Google and Wikipedia?
@random-xl3zm11 ай бұрын
odin project ? lets do it hare krishna
@whatever636444 жыл бұрын
I have a question, what if the number of elements in a sub-array were to be an even number instead of an odd number? Do I round it or just take the integer part?
@ضحكتكتهمنا-ط3ر4 жыл бұрын
@@kariimnabiil-911 when the number is 5 the middle ==3 in humanity but in code from 0 what I do when the number is big and I don't need code you understand me, please If you understand, please reply me.
@julianarchila36714 жыл бұрын
You use a round function
@alialparslan22883 жыл бұрын
I think it is up to you. It can be a round function, you can take the int value, or you can look through the middle two number separately ( it will not be the best design, but it's possible) or any other idea. The key is finding the best approach. And i guess, your suggestions are good enough
@ktswjp4 жыл бұрын
Great job, Dough! Keep it up. You divided this problem to as simple as possible chunks.
@ilyesbenmalti94025 ай бұрын
How's life bro
@sithoidinh38913 жыл бұрын
Binary search is much more better than linear search!!!
@mohammadkermani29874 жыл бұрын
Awesome! It was a pretty simple explanation and easy to understand. I enjoyed the way he was explaining in detail and showing it visually! thanks a lot
@LoneWolf59606 жыл бұрын
I'm still trying to wrap my head @7:33 how does the looping logic turn to "Repeat until the (sub)array is of size 0" based on the upper right hand table in the corner. What does "(sub)array is of size 0" mean anyway?
@kitpaovm85375 жыл бұрын
when start point is greater than end point, you can inffer that the subarray is size 0
@theorbit176 жыл бұрын
my mans
@xxRuleZzZxx4 жыл бұрын
@Matthew Mcclintic le mans 24 hrs
@deronburton29944 жыл бұрын
Does it only work with a linear arrays?
@Street_Food_Adventuress7 жыл бұрын
Awesome !! Continue guys !!
@NinjaJutsu-y4d10 ай бұрын
Great content
@mortimerc317 Жыл бұрын
thank you
@swanandpangam7 жыл бұрын
But why doesn't we calculate the sorting time as it is the necessary prerequisite?
@abhinvra7 жыл бұрын
Binary search is used only for sorted arrays.
@abhinvra7 жыл бұрын
It's not a sorting algorithm but a searching one.
@abhinvra7 жыл бұрын
For example you can make use of a sorting algorithm such as Merge sort to sort the array and then use Binary search to find if an element is present in there.
@jayant91516 жыл бұрын
ajfjeoaiodjkajgd report
@andreasv94722 жыл бұрын
Because they are two separate operations. Maybe you make thousands of searches for each time you make a sort. In practical terms, if you have sorted one billion webpages (if you are google for example), then you only care how quickly you can give search results to the user. You do not sort the webpages each time someone makes a search on google. You sort them once in a while, and then you allow maybe millions of searches on that array until the next time you sort it. So the speed of the search is what matters here, not the speed of the sort as it is likely to be done in advance, and only once in a while.
@maxim5519 Жыл бұрын
thanks!
@sakib22492 жыл бұрын
what if array size is 15.
@LUITEN14 жыл бұрын
Would someone elaborate on the Log n part? Why doesnt that log have a base? I get that as long as n increases, so will the lenght of time (in the linear search case) but I dont fully get it..
@callumross76824 жыл бұрын
In math you tend to presume the base is 10 if it is not given
@exnihilonihilfit63164 жыл бұрын
If you go two thirds down this page to the section entitled _"But Sometimes There Is Confusion ... !"_ , you'll see a little discussion of it: www.mathsisfun.com/algebra/logarithms.html But in this case, the base is 2. n=1 log[2](1)=0 n=2 log[2](2)=1 n=3 log[2](3)=1.58496 n=4 log[2](4)=2 n=5 log[2](5)=2.32192 n=6 log[2](6)=2.58496 n=7 log[2](7)=2.80735 n=8 log[2](8)=3 n=9 log[2](9)=2log[2](3)=3.16992 David Malan talked about it in the lecture (link has timestamp): kzbin.info/www/bejne/nKrOo5-nl7tsra8
@elia552 Жыл бұрын
@@callumross7682 for anyone else reading this now, in computer science you presume the log to be 2, NOT 10
@kieffel7013 Жыл бұрын
@@elia552 thanks! if the size of the array is 15, in the worst case scenario it should take 4 iterations right?
@elia552 Жыл бұрын
@@kieffel7013 honestly I stopped learning coding and computer science and this is gibberish to me
@krupasankari5 жыл бұрын
Doug Lloyd really looks like Doug Mcquaid lol
@TheThirdlevel-un8do Жыл бұрын
Nice sir
@TheThirdlevel-un8do Жыл бұрын
Nice teach you
@nurgisaandasbek4 жыл бұрын
Super!
@samuelfey49244 жыл бұрын
we go to the middle I understand that perfectly but how do we chouse either right or left? cause we dont know where that number .
@alim.78414 жыл бұрын
Binary search algorithm works for only sorted arrays so if you find in the middle number less than your target you have go right because there you will find bigger numbers, watch this 0:30
@brendonspears11642 жыл бұрын
Bro said everything except show the code
@2low2rl5 жыл бұрын
Why does he seem to be annoyed at his imaginary student? lol
@mashraful50653 жыл бұрын
his hair makes me not understand everything I understood