Binary Search - CS50 Shorts

  Рет қаралды 133,344

CS50

CS50

Күн бұрын

Пікірлер: 61
@GY-yv5cz
@GY-yv5cz Жыл бұрын
Probably my favourite algorithm. Any time I know a dataset is sorted, I just want to employ this.
@troyke
@troyke 4 жыл бұрын
Thank you Doug! As always, a very clear explanation, with visuals to help support your points!
@omaroats
@omaroats 6 жыл бұрын
Perfect. This was well explained and easy to follow. Thank you Doug ❤︎
@candicehwt6375
@candicehwt6375 4 жыл бұрын
every time he asked a question, I was like no please don't pick me to answer, I don't know
@ojalafsenior4757
@ojalafsenior4757 Жыл бұрын
Very well elaborated Doug
@codeklaudia9696
@codeklaudia9696 5 ай бұрын
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
@mandaleswaranthasarathakum3130
@mandaleswaranthasarathakum3130 5 жыл бұрын
Thanks man helped with my computing test on search and sorts
@hugger-bd5ij
@hugger-bd5ij 4 жыл бұрын
Matthew Mcclintic why
@vk-hm6te
@vk-hm6te 4 жыл бұрын
@Matthew Mcclintic why
@MR0IAM0WATCHING0U
@MR0IAM0WATCHING0U 4 жыл бұрын
@Matthew Mcclintic why
@matthewmcclintic5488
@matthewmcclintic5488 4 жыл бұрын
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.
@matthewmcclintic5488
@matthewmcclintic5488 4 жыл бұрын
I thought the video was very helpful too and it was not my place to say something like that.
@TheInvestmentCircle
@TheInvestmentCircle 5 жыл бұрын
I wish there were coding examples in these videos :[
@Dinopeach
@Dinopeach 4 жыл бұрын
check big-o.io
@exnihilonihilfit6316
@exnihilonihilfit6316 2 жыл бұрын
Ever heard of Google and Wikipedia?
@random-xl3zm
@random-xl3zm 11 ай бұрын
odin project ? lets do it hare krishna
@whatever63644
@whatever63644 4 жыл бұрын
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ر
@ضحكتكتهمنا-ط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.
@julianarchila3671
@julianarchila3671 4 жыл бұрын
You use a round function
@alialparslan2288
@alialparslan2288 3 жыл бұрын
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
@ktswjp
@ktswjp 4 жыл бұрын
Great job, Dough! Keep it up. You divided this problem to as simple as possible chunks.
@ilyesbenmalti9402
@ilyesbenmalti9402 5 ай бұрын
How's life bro
@sithoidinh3891
@sithoidinh3891 3 жыл бұрын
Binary search is much more better than linear search!!!
@mohammadkermani2987
@mohammadkermani2987 4 жыл бұрын
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
@LoneWolf5960
@LoneWolf5960 6 жыл бұрын
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?
@kitpaovm8537
@kitpaovm8537 5 жыл бұрын
when start point is greater than end point, you can inffer that the subarray is size 0
@theorbit17
@theorbit17 6 жыл бұрын
my mans
@xxRuleZzZxx
@xxRuleZzZxx 4 жыл бұрын
@Matthew Mcclintic le mans 24 hrs
@deronburton2994
@deronburton2994 4 жыл бұрын
Does it only work with a linear arrays?
@Street_Food_Adventuress
@Street_Food_Adventuress 7 жыл бұрын
Awesome !! Continue guys !!
@NinjaJutsu-y4d
@NinjaJutsu-y4d 10 ай бұрын
Great content
@mortimerc317
@mortimerc317 Жыл бұрын
thank you
@swanandpangam
@swanandpangam 7 жыл бұрын
But why doesn't we calculate the sorting time as it is the necessary prerequisite?
@abhinvra
@abhinvra 7 жыл бұрын
Binary search is used only for sorted arrays.
@abhinvra
@abhinvra 7 жыл бұрын
It's not a sorting algorithm but a searching one.
@abhinvra
@abhinvra 7 жыл бұрын
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.
@jayant9151
@jayant9151 6 жыл бұрын
ajfjeoaiodjkajgd report
@andreasv9472
@andreasv9472 2 жыл бұрын
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
@maxim5519 Жыл бұрын
thanks!
@sakib2249
@sakib2249 2 жыл бұрын
what if array size is 15.
@LUITEN1
@LUITEN1 4 жыл бұрын
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..
@callumross7682
@callumross7682 4 жыл бұрын
In math you tend to presume the base is 10 if it is not given
@exnihilonihilfit6316
@exnihilonihilfit6316 4 жыл бұрын
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
@elia552 Жыл бұрын
@@callumross7682 for anyone else reading this now, in computer science you presume the log to be 2, NOT 10
@kieffel7013
@kieffel7013 Жыл бұрын
@@elia552 thanks! if the size of the array is 15, in the worst case scenario it should take 4 iterations right?
@elia552
@elia552 Жыл бұрын
@@kieffel7013 honestly I stopped learning coding and computer science and this is gibberish to me
@krupasankari
@krupasankari 5 жыл бұрын
Doug Lloyd really looks like Doug Mcquaid lol
@TheThirdlevel-un8do
@TheThirdlevel-un8do Жыл бұрын
Nice sir
@TheThirdlevel-un8do
@TheThirdlevel-un8do Жыл бұрын
Nice teach you
@nurgisaandasbek
@nurgisaandasbek 4 жыл бұрын
Super!
@samuelfey4924
@samuelfey4924 4 жыл бұрын
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.7841
@alim.7841 4 жыл бұрын
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
@brendonspears1164
@brendonspears1164 2 жыл бұрын
Bro said everything except show the code
@2low2rl
@2low2rl 5 жыл бұрын
Why does he seem to be annoyed at his imaginary student? lol
@mashraful5065
@mashraful5065 3 жыл бұрын
his hair makes me not understand everything I understood
@ProVishGaming
@ProVishGaming 5 жыл бұрын
Who here is from Mrs.Denna’s class?
@talhatariqyuluqatdis
@talhatariqyuluqatdis 7 жыл бұрын
1
@talhatariqyuluqatdis
@talhatariqyuluqatdis 7 жыл бұрын
St
@sachascarabello7843
@sachascarabello7843 3 жыл бұрын
bogos binted
Hash Tables - CS50 Shorts
18:47
CS50
Рет қаралды 149 М.
Binary Search Algorithm - Computerphile
18:34
Computerphile
Рет қаралды 164 М.
ТВОИ РОДИТЕЛИ И ЧЕЛОВЕК ПАУК 😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН
Computer Scientist Answers Computer Questions From Twitter
14:27
How Binary Search Makes Computers Much, Much Faster
6:51
Tom Scott
Рет қаралды 1,4 МЛН
Bubble Sort - CS50 Shorts
5:55
CS50
Рет қаралды 123 М.
2 Years of C++ Programming
8:20
Zyger
Рет қаралды 6 М.
Binary Search - A Different Perspective | Python Algorithms
8:56
Bug in Binary Search - Computerphile
11:31
Computerphile
Рет қаралды 288 М.
Recursion - CS50 Shorts
13:50
CS50
Рет қаралды 171 М.
Lecture 5: Binary Search Trees, BST Sort
52:40
MIT OpenCourseWare
Рет қаралды 615 М.
Command Line - CS50 Shorts
17:52
CS50
Рет қаралды 119 М.