Algorithms: Binary Search

  Рет қаралды 997,038

HackerRank

HackerRank

Күн бұрын

Пікірлер: 277
@BigJDawg6969
@BigJDawg6969 7 жыл бұрын
That keyboard click is very satisfying
@BrianFaure1
@BrianFaure1 7 жыл бұрын
It's like a rubber mat or something
@im-a-trailblazer
@im-a-trailblazer 7 жыл бұрын
Someone now gets the idea of Binary Search..
@Samdroid_
@Samdroid_ 7 жыл бұрын
try mechanical keyboards you will love it
@iNet16
@iNet16 6 жыл бұрын
macbook keyboard
@nikhilnagrale
@nikhilnagrale 4 жыл бұрын
@@iNet16 they are boring mechanical keyboards are best
@yvesbff5107
@yvesbff5107 6 жыл бұрын
love having a test tomorrow​ on something you know nothing about
@allroundlad
@allroundlad 6 жыл бұрын
I relate to this religiously
@selenatorbirdie9305
@selenatorbirdie9305 4 жыл бұрын
I have the test today in like an hour 😂
@ll-sz9fl
@ll-sz9fl 4 жыл бұрын
But more I love Ariana ♥️
@abbGames2000
@abbGames2000 4 жыл бұрын
Basically half an hour left for my exam and still need to learn this and bubblesort algorithms
@gueloremanuel2639
@gueloremanuel2639 4 жыл бұрын
@@allroundlad ...
@MichaelCarolin
@MichaelCarolin 6 жыл бұрын
A key thing to know about binary search is that is not strictly limited to sorted arrays. It's just a method for efficiently narrowing a search range (in log(n) steps) in order to find a value that meets a criteria. You can use binary search to find the median in an unsorted array, for instance.
@bcoz1492
@bcoz1492 Жыл бұрын
could you explain why it doesn't need to be sorted? are you referring to quickselect?
@drakata27
@drakata27 Жыл бұрын
explain it lil bro
@alexcomas2934
@alexcomas2934 5 жыл бұрын
This is such a simple implementation. Other places have an overcomplicated solution lol.
@memo6032
@memo6032 2 жыл бұрын
For anyone wondering why we need to add the first number to the last number, after all it doesn't make sense when our first element is 0 or 1, we do that becuase it's necessary when we go deeper through the array. If you are at the 6th element, for example, and the 9th element is your last element, adding them together is necessary to get the middle element.
@charlesikemefuna6481
@charlesikemefuna6481 6 жыл бұрын
Thanks for this Gayle. Great theoretical overview with an example to illustrate the point, followed by the hands on coding implementation. Truly great stuff.
@TheMrkazsam
@TheMrkazsam 6 жыл бұрын
Great video, made a confusing two hour lecture make sense in 6 and a half minutes.
@ayushsingh9732
@ayushsingh9732 4 жыл бұрын
I read her answers on quora for so long, but I didn't even know she was so famous
@its_neel_ok
@its_neel_ok 3 жыл бұрын
whats her @
@zackogoma2800
@zackogoma2800 5 жыл бұрын
my name is zach,my bro is andy.What a coincidence
@cinquain0
@cinquain0 5 жыл бұрын
That’s the best description of binary search I’ve ever heard
@traviswentz4248
@traviswentz4248 6 жыл бұрын
These videos are so nice. They're concise and clear in their explanations. Thanks for the videos Gayle Laakmann McDowell and HackerRank!
@betocollin
@betocollin 7 жыл бұрын
If you do this in Javascript, don't forget to Math.floor it: const mid = Math.floor(left + ((right - left) / 2));
@robbeandredstone7344
@robbeandredstone7344 4 жыл бұрын
Why does everything have to bee floored in JS?
@Azelphur
@Azelphur 4 жыл бұрын
​@@robbeandredstone7344 In Java, you are using Integers. Integers can only be whole numbers (so no decimal place). When you do Integer division, you always floor the result. So to use a real world example, lets say array.length is 8. Therefore left is 0, right is 7 (since array.length-1 = 7) In Java, you are running int mid = 0 + ((7 - 0) / 2);. This is 3.5, but that's not an integer. The result gets floored and becomes 3. mid gets set to 3, and on the next line you try and access array[3] - this works fine. In Javascript, you are using its "number" type, which is actually a float. So mid = 0 + ((7 - 0) / 2); sets mid to 3.5. Then on the next line you try and access array[3.5], and as you can imagine, things go wrong from there. It's always important to know how your programming language (and even version of that language) handles division, for example, Python 3.x returns a float for all division, while Python 2.x returns an integer.
@robbeandredstone7344
@robbeandredstone7344 4 жыл бұрын
Thanks
@jandrorojas6714
@jandrorojas6714 4 жыл бұрын
@@robbeandredstone7344 and why do everybody have to throw some shade about JS?
@bikeshbaral1685
@bikeshbaral1685 4 жыл бұрын
why we should use left+(right-left)/2 instead of (Left+right)/2 . or what does data overflow really mean.
@Bayo106
@Bayo106 4 жыл бұрын
I have no clue why some people do the first one as the second one is easier to understand and shorter
@rodrigocolasso
@rodrigocolasso 4 жыл бұрын
bikesh baral If you sum two integer you could overflow the variable ( put more value than the variable can handle). With the second option this scenario would never happen.
@patrickstival6179
@patrickstival6179 6 жыл бұрын
I think it starts well but when she dives into code it gets confuse. Feels like it needs more explanation or abstraction while she writes it down, such as a line-to-line description. Many people got confused about the overflow-prevention expression and the mid point manipulation.
@nickgattuso
@nickgattuso 6 жыл бұрын
You just need more experience programming then. I found this very easy to follow. Thats why this is a video series. You can easily pause the video and think, rewind etc.
@namlehai2737
@namlehai2737 5 жыл бұрын
Makes perfect sense but only because ive known this already. Yeah...
@UnrecycleRubdish
@UnrecycleRubdish 4 жыл бұрын
Exactly. She assumes way too much and skips many steps. Regardless of programming level, this is a poor way of teaching.
@centurion8158
@centurion8158 4 жыл бұрын
This is such a wonderful explanation on this topic, i've been struggling with this for a while
@shawnscientifica6689
@shawnscientifica6689 7 жыл бұрын
In practice I highly suggest to never tweak unless absolutely necessary. It's too easy to tweak yourself into a debugging hell where you could have rewrote the method by the time you solve it
@zauberfrosch11
@zauberfrosch11 4 жыл бұрын
I only watched through the basic explanation, because I forgot how binary search worked in principle. Really nice way of explaining and I also like how you explained the meaning of the log(n)
@jonsnow9246
@jonsnow9246 5 жыл бұрын
Liked the way you handled the overflow. :)
@saniyakhan9989
@saniyakhan9989 3 жыл бұрын
i love how you made it look so freaking easy.
@hernanphillip334
@hernanphillip334 7 ай бұрын
It's so clear and well explained, thank you ma'am
@bimgonzaga
@bimgonzaga 3 жыл бұрын
Great explanation! Thank you! But if you are searching a number bigger than your maximum element in the array, it will through a ArrayIndexOutOfBoundException. We need to cover that edge case with: if (left > right || right >= array.length) { return false; }
@miguelarce452
@miguelarce452 2 жыл бұрын
I was making this mistake at first, I was passing "array.length" on the initial function call then I realized that you have to pass "array.length - 1" instead. Then there's no need to add that extra check.
@latedeveloper7836
@latedeveloper7836 3 жыл бұрын
4:10 nice tip on how to avoid overflow error in Java.
@goodwish1543
@goodwish1543 5 жыл бұрын
Thanks for professional knowledge sharing. Why we need ``` while (left
@Manu-wb2uv
@Manu-wb2uv 5 жыл бұрын
You won't be able to check the last element. Take this array for example [1,2,3]. You're looking for 3. First iteration: left= 0, right= 2, mid = (0+2)/2=1, is 3=2 ? false, is 3
@pankaj3746
@pankaj3746 3 жыл бұрын
I wish there are more women in IT! More power to you Gayle, you're doing a fabulous job!
@muchen303
@muchen303 6 жыл бұрын
That while condition left
@omarmalik5099
@omarmalik5099 5 жыл бұрын
I think you meant left -1 < right
@rolandovillcaarias5112
@rolandovillcaarias5112 2 жыл бұрын
Thank you so much, what font are you using in the Eclipse Editor please. It looks comfortable for my eyes.
@kitchiong2861
@kitchiong2861 4 жыл бұрын
Thanks for the awesome video. Just one question that I can't wrap my head around, can right start with arr.length instead of arr.length - 1? Is there any counterexample? Thanks!
@Aliennnaa
@Aliennnaa 4 жыл бұрын
in most programming languages array starts from 0 , so for an array of length =n the last element will be at position n-1 meaning at arr.length-1 so no you cant start right with arr.length
@dijoxx
@dijoxx 4 жыл бұрын
Arrays use 0-based indexes in Java. So arr[0] refers to the first element of the array. Following that logic, arr[arr.length - 1] gives you the last element.
@sanjsin
@sanjsin 6 жыл бұрын
Pretty simple explanation of binary search, i studied this in 1992, visited this link to explain my highschooler daughter for ap comp science.
@ashwinipowar2230
@ashwinipowar2230 4 жыл бұрын
Mam ,if the elements of array are not in a sorted order(for binary search) then we should make it in sorted order and solve the question or we cannot apply Binary search for unsorted elements?
@roman3249
@roman3249 4 жыл бұрын
This implementation doesn't work if the array has repeated elements though. It should be slightly changed for that situation.
@SnowDragon894163
@SnowDragon894163 3 жыл бұрын
changed how?
@quentinz6291
@quentinz6291 5 жыл бұрын
1:35 "must be sorted", yeah, that's why inOrder traversal is important in a BST
@LokeshBarla
@LokeshBarla 2 жыл бұрын
Thanks so much.... It's simple and sweet when explained this brilliantly.
@ngoviethung801
@ngoviethung801 2 жыл бұрын
Very informative, straightforward thank you
@richashalini1068
@richashalini1068 2 жыл бұрын
Wow, such am amazing explanation Gayle
@Bee4Brendan
@Bee4Brendan 6 жыл бұрын
Now that I explained it in a decent manner, let's make it confusing just in case you understood it.
@amy-cx9ok
@amy-cx9ok 6 жыл бұрын
hahahahha
@hakami1426
@hakami1426 2 жыл бұрын
Is left and right the indexes themselves or the values?
@wenjieyu6242
@wenjieyu6242 3 жыл бұрын
Thanks! The presentation is really nice, easy to understand and very clear!
@FLYAEROBOY
@FLYAEROBOY 6 жыл бұрын
if (left > right) { return false; } What does that even mean? Assuming it's a Sorted Array, how will left > right ?? Can you someone explain what she means by the first if( left > right ) statement
@mohammadhanifahnurshafrudi8208
@mohammadhanifahnurshafrudi8208 6 жыл бұрын
maybe its to check the array is sorted or not .
@floatingscrib
@floatingscrib 6 жыл бұрын
That if statement essentially checks if int x is not in the array. Remember that the integers left, mid, and right are indexes for the array. Lets say that left starts out as 0 and right is 24. This puts mid at 12. Lets say int x is smaller than array[left]. This would mean that x is smaller than array[mid]. Under recursion or iteration, right will be come mid-1, which is 11. Mid therefore becomes 11/2 = 5. becomes Repeating this loop will still show that x is smaller than array[mid], considering that it's still smaller than array[left]. Therefore right becomes mid-1 again, aka 5-1 = 4. This will continue to repeat. Mid becomes 4/2 = 2, and right is 2-1 = 1. Mid becomes 1/2 = 0, and right becomes 0-1 = -1, making left > right. We can do this in the opposite direction where x is greater than array[right], which progressively increases left . Going through the loops, with mid at 12, left will be 12+1 = 13. This will put mid at (13+24)/2 = 18 and left as 18+1 = 19. The next loop will be mid at (19+24)/2 = 21 and left at 21+1 = 22. Then, mid is (22+24)/2 = 23 and left as 23+1 = 24. Finally mid becomes (24+24)/2 = 24 and left is 24+1 = 25, making left > right.
@dhavalsoni9941
@dhavalsoni9941 4 жыл бұрын
Any time, Left > Right means, Array is not sorted so not to proceed with. As this technique on sorted array only. If array is not sorted or rotated then, its other way around to go with Divide and conquer (quick sort) approach.
@HugoAyala1983
@HugoAyala1983 4 жыл бұрын
Great explanation and examples for recursive and iterative approach!
@aniketmasram6500
@aniketmasram6500 3 жыл бұрын
I wish I had a teacher like you 🙂🙂
@MinisterGold
@MinisterGold 6 жыл бұрын
Zach... that detached head... just caught me off guard.
@PrincessSarahjayne11
@PrincessSarahjayne11 2 жыл бұрын
Great video, made that very easy to understand !
@JamesBrodski
@JamesBrodski 2 жыл бұрын
Great video! Thank you so much. I finally understand.
@srinivasadineshparupalli5139
@srinivasadineshparupalli5139 5 жыл бұрын
Hi, Can you please let me know what is the algorithm name which does all the binary tree operations(like breadh-first, preorder, inorder ets). thanks.
@syedahkam7164
@syedahkam7164 3 жыл бұрын
well this is easier than i expected it to be
@haneulkim4902
@haneulkim4902 4 жыл бұрын
1. how does computer pick its mid point? 2. when there are two elements left, which one does it choose?
@Breakout1345
@Breakout1345 4 жыл бұрын
Answer to 1 : midpoint is chosen by (left + right)/2; Answer to 2: it chooses the 1st element (n/2 = floor(n/2) by default)
@haneulkim4902
@haneulkim4902 4 жыл бұрын
@@Breakout1345 Yes, I was just confused because I didn't know low,high refers to index, not the element value.
@lemardyc
@lemardyc 6 жыл бұрын
I am a teacher and if I was searching for Zack (are they really sorted by first name?), I would do a linear search from the back.
@olorinorphique
@olorinorphique 6 жыл бұрын
Ok what if all your student's first name start with a Z or a Y . And you have 3000 students. You picked the best case scenario. Big O notation is all about the worst case scenario. In my case, which is worst case. Binary LogN is still a lot faster than your linear from the back of the stack search. Peace.
@irwingoh94
@irwingoh94 6 жыл бұрын
Did Zack do something wrong? Why do you need to find him?
@RussTeeTrombone
@RussTeeTrombone 6 жыл бұрын
That's why you're a teacher and not a software engineer
@thorn8485
@thorn8485 6 жыл бұрын
If you know something about your data, that's great. Algorithms are for the general case, when you don't know anything super specific about your data and you always need to return the correct answer, i.e all you know about what paper you're looking for is that the name starts with A-Z and that the papers are sorted alphabetically.
@eduardodelgado7873
@eduardodelgado7873 6 жыл бұрын
Linear search hmm what if it's not in sorted in order 😂
@marq_8976
@marq_8976 2 жыл бұрын
Excellent explanation.
@Vibestr
@Vibestr 6 жыл бұрын
For the recursive example, anyone know why she two of the same methods (binarySearchRecurive()) with different number of parameters? That's kind of confusing. Also how would the program find the midpoint if we are dealing with an array with 10 items? Would it round up to the 5th index?
@RRWX
@RRWX 4 жыл бұрын
Now i know every thing about coding!
@shahabyaftali3848
@shahabyaftali3848 4 жыл бұрын
for a couple of seconds i though i lost right side of my headphones XD
@veraqiu6734
@veraqiu6734 4 жыл бұрын
hey there, can you explain why we put (left
@siobhanahbois
@siobhanahbois 4 жыл бұрын
You won't be able to check the last element. Take this array for example [1,2,3]. You're looking for 3. First iteration: left= 0, right= 2, mid = (0+2)/2=1, is 3=2 ? false, is 3
@oln1908
@oln1908 4 жыл бұрын
Me taking notes of binary search only to be distracted by that satisfying keyboard click
@manoelramon8283
@manoelramon8283 5 жыл бұрын
left+((right-left)/2 still can overflow
@wonimpty
@wonimpty 3 жыл бұрын
what if its even number and you cant find the median(the middle number of the array)?
@FuzzyDPozzy
@FuzzyDPozzy 3 жыл бұрын
The tutorial was good till 2:40 , then you show up code and I wasn't able to understand anything unfortunately. However I do know how to do this on my own which I will do, but this was a while back so I can understand. All I am saying this could have been implemented and understood easily if only the structure of the code was better and more importantly simpler.
@stevenshrii
@stevenshrii 2 жыл бұрын
With no duplications of elements the array
@josealb2
@josealb2 4 жыл бұрын
The iterative version implemented at the end returns true and false but should return the index
@asero82.
@asero82. 4 жыл бұрын
Both versions returns a boolean meaning what your searching for is or not in the array
@bitti1975
@bitti1975 6 жыл бұрын
Why not (left+right) >>> 1? It's shorter and faster
@goodwish1543
@goodwish1543 5 жыл бұрын
谢谢大师分享,请问这里为什么需要小于等于 start
@leomonz
@leomonz 5 жыл бұрын
The coding is very confusing because she was not doing actual coding, just abstract coding there..... Although abstract coding is fine but really confuse people who trying to follow as they haven't done it before
@ahmadalalwani5176
@ahmadalalwani5176 7 жыл бұрын
thanks for confusing
@viddusliteracy9087
@viddusliteracy9087 6 жыл бұрын
Ahmad Al Alwani hehehehe hahaha..for me to
@ton_
@ton_ 5 жыл бұрын
@@123214matt then don't watch, noob
@paulvincentdesamparado5817
@paulvincentdesamparado5817 2 жыл бұрын
how to run the recursive implementation code ????
@NachiketJoshiTheBloodMage
@NachiketJoshiTheBloodMage 7 жыл бұрын
why one of the parameters of binarySearchRecursive is (array.length - 1) and not (array.length)?
@patrickvanvorce2670
@patrickvanvorce2670 7 жыл бұрын
To add on to the 0 indexing, that last element in an array is null, so when she says array.length-1 it is making sure it is accessing the last data input and not the null char.
@lethanhan9084
@lethanhan9084 3 жыл бұрын
anybody know why: 1. the top pointer need to be inclusive 2. when replacing low and high, it will be mid + 1 and mid - 1 respectively?
@thatoneuser8600
@thatoneuser8600 3 жыл бұрын
Idk what you mean by 1, but for 2: Because if we don't do that, then we rely on the 'mid' variable to solely push us to the base case, which can lead it to get stuck due to the rounding down when dividing, and thus, receiving a StackOverflowError if the target is the very last number of the sorted dataset. No matter what, it will never be able to reach the last index since odd + even = odd, and divided by 2 where it rounds down would equal the smaller (left) integer of the pair, creating an infinite loop.
@farahizzati5676
@farahizzati5676 4 жыл бұрын
THANK YOU SO MUCH I TOTALLY UNDESTAND IT NOW:)
@Stealth7596
@Stealth7596 7 жыл бұрын
what is the difference between (left + right)/2 and left + ((right - left)/2) ?
@munnat8073
@munnat8073 7 жыл бұрын
to prevent overflow in java
@EnriqueMoranG
@EnriqueMoranG 2 жыл бұрын
Thanks ma'am
@anshitkumar6347
@anshitkumar6347 7 жыл бұрын
The vocal fry's too strong here
@Caldera510
@Caldera510 7 жыл бұрын
Very nice! Thanks!
@sampurnanand3379
@sampurnanand3379 3 жыл бұрын
what are the time complexities of iterative and recursive versions?
@sampurnanand3379
@sampurnanand3379 3 жыл бұрын
And also the space complexitites
@SathishKumar-yw4qs
@SathishKumar-yw4qs 6 жыл бұрын
Can u say what is the software u r using.....
@makii1715
@makii1715 5 жыл бұрын
I know this is like 10 months ago but if you still want to know : probably Eclipse
@warnercooler4488
@warnercooler4488 3 жыл бұрын
Thank you so much!
@faisaladil5793
@faisaladil5793 4 жыл бұрын
excellent work.
@christopher5731
@christopher5731 6 жыл бұрын
These videos are usually pretty good. This one... not so much
@MrDeeb00
@MrDeeb00 2 жыл бұрын
Brilliant Thank You! 🌹
@CristianMihalyi
@CristianMihalyi 7 жыл бұрын
Why could it overflow if (left+right)/2? The mid position is always in the array, isn't it?
@VS-ey2lf
@VS-ey2lf 7 жыл бұрын
+Britka sablja Thank you so much for the explanation!! I was wondering for an hour why is it like that.. Thanks again
@philtrem
@philtrem 7 жыл бұрын
It's got to do with the max value a given integer type can hold, not to be confused with index out-of-bound errors.
@RABANAND
@RABANAND 6 жыл бұрын
But the value will be assigned to the variable after the division of 2 right. So in this case , How overflow is going to happen?? Please clarify
@dk-sky3820
@dk-sky3820 6 жыл бұрын
Anand R (left + right) is stored in temporary int (behind the scene) to be divided. If it's more than 2^31 you're toasted...
@irasanchez1265
@irasanchez1265 4 жыл бұрын
Thank you for making this!
@mathiasyeremiaaryadi9097
@mathiasyeremiaaryadi9097 6 жыл бұрын
Why right is mid -1 ? why not mid + 1??
@kenocvr
@kenocvr 6 жыл бұрын
Binary Search is cutting down the problem space (where to look) at every step in the algorithm. Right is on the "right" side of the array (at the end position). Left moves toward the mid (goes right) and right moves toward the mid (goes left). There would be no reason to increase the right position. Just like there would be no reason to decrease the left position.
@Yilz19
@Yilz19 4 жыл бұрын
Shoutout to all ma procrastiboiis
@benito2056
@benito2056 3 жыл бұрын
Nice.
@shamsansari
@shamsansari 5 жыл бұрын
why is the method a boolean, shouldn't it be int?
@tugcehilal2536
@tugcehilal2536 4 жыл бұрын
it returns true if it "finds" the element. this is a search algorithm
@Ishaaq92
@Ishaaq92 4 жыл бұрын
where did Andrew come from?
@supergoodwhite
@supergoodwhite 3 жыл бұрын
does anyone have any answers for Challenge: Binary search
@vladimir781
@vladimir781 6 жыл бұрын
int mid = low + ((high - low) / 2);
@skril733
@skril733 5 жыл бұрын
int mid = (low + high)/2
@irynaprokopenko6438
@irynaprokopenko6438 5 жыл бұрын
Vladimir, yes, correct
@yoowon-hye9270
@yoowon-hye9270 5 жыл бұрын
Or ((high+low)/2)?
@reshmayasmin9717
@reshmayasmin9717 5 жыл бұрын
Can we do it with for loop?
@robbeandredstone7344
@robbeandredstone7344 4 жыл бұрын
Yes you can, just do for(int i = 0; i
@gabrielpereiramendes3463
@gabrielpereiramendes3463 5 жыл бұрын
Very Good!
@a.d.477
@a.d.477 5 жыл бұрын
made a confusing one hour lecture make sense in 6
@irinish
@irinish 5 жыл бұрын
what if there were 12 numbers instead of 11? What would be the mid then?
@thisisbob1001
@thisisbob1001 5 жыл бұрын
Good question
@yoowon-hye9270
@yoowon-hye9270 5 жыл бұрын
For arrays of even lengths, the midpoint index will always be the quotient of array.length/2. In your case, someArray.length -> 12. Thus, mid = someArray[6].
@yahyahassan7499
@yahyahassan7499 5 жыл бұрын
Is it my school or something I'm 12 and have a test on this tommorow these grades will determine if I have dropped or grew from last term 1 like 1 prayer I will pass
@nicholasfurlonger8796
@nicholasfurlonger8796 5 жыл бұрын
i hope you failed yahya
@ng4logic
@ng4logic 4 жыл бұрын
Yeah every 12 year old should know binary search
@good_life_videos
@good_life_videos 3 жыл бұрын
recursively and irr... what? 5:55
@theguardianarchives433
@theguardianarchives433 3 жыл бұрын
Iterative
@sandeepmehra5760
@sandeepmehra5760 4 жыл бұрын
BEST VIDEO
@ryn0904
@ryn0904 4 жыл бұрын
This just confused me even more
@benmiles1505
@benmiles1505 3 жыл бұрын
I doubt that there are many names that come after Zach so you shoud just go to the end and work backwards. smh my head
@thecandel5479
@thecandel5479 4 жыл бұрын
Very nice! 🌹
@nadiasd5914
@nadiasd5914 6 жыл бұрын
good job! very good explanations>
@cuiatk9492
@cuiatk9492 2 жыл бұрын
How to Dry Run The Recursive CURSE! My Brain Cells are Dying.!!
@danval407
@danval407 6 жыл бұрын
I'll have the coffee shes drinking
@Jonathan-od5xc
@Jonathan-od5xc 5 жыл бұрын
dan val LOL
@mathaalbhai
@mathaalbhai 6 жыл бұрын
This is one most confusing binary search for beginners!
@praneelmadhuvanesh3770
@praneelmadhuvanesh3770 2 жыл бұрын
wtf is the point if the arrya has to be sorted. that means u must have already found the thing before
@zombie8956
@zombie8956 2 жыл бұрын
Just because it's sorted doesn't mean you have O(logn) lookup automatically. For example, if I asked you to guess a number between 1-100, would it be faster to go through every number or to start at the mid point, ask if its higher or lower, then create a new midpoint?
Algorithms: Solve 'Shortest Reach' Using BFS
4:43
HackerRank
Рет қаралды 173 М.
Binary Search in Java - Full Simple Coding Tutorial
17:48
Coding with John
Рет қаралды 122 М.
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 15 МЛН
兔子姐姐最终逃走了吗?#小丑#兔子警官#家庭
00:58
小蚂蚁和小宇宙
Рет қаралды 10 МЛН
Fake watermelon by Secret Vlog
00:16
Secret Vlog
Рет қаралды 28 МЛН
Ouch.. 🤕⚽️
00:25
Celine Dept
Рет қаралды 22 МЛН
Binary Search Algorithm - Computerphile
18:34
Computerphile
Рет қаралды 162 М.
Data Structures: Trees
9:57
HackerRank
Рет қаралды 1 МЛН
Algorithms: Bit Manipulation
9:06
HackerRank
Рет қаралды 538 М.
2.6.1 Binary Search Iterative Method
19:36
Abdul Bari
Рет қаралды 821 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
How I Failed the Google Coding Interview (and lessons I learned)
14:24
3 Types of Algorithms Every Programmer Needs to Know
13:12
ForrestKnight
Рет қаралды 488 М.
Bug in Binary Search - Computerphile
11:31
Computerphile
Рет қаралды 286 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 624 М.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 421 М.
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 15 МЛН