2:03 if its less or equal? with a single code line you can check if its equal and only continue if its less, no need to search any longer if it is equal, but still great tutorial
The pseudo-code you provided does not work for finding the last element in the array. The simple fix for this is to add an else if statement after the if( A[low] == target ) statement checking for the value at A[high]. Here is the code you would add: else if ( A[high] == target ) { return high; }
@MrDavidVuong I thought that at first, but think about it; that means one more test at every single step, so a 50% increase in time at each step; you're trading a potentially reduction in the number of steps, for an increase in the time each step takes. For more than a relatively tiny dataset, you're better not performing the equals test.
It's unfortunate that linear searches are sometimes needed, because the fastest known sorting algorithms are slower than O(n) in the average case, so sorting followed by a binary search is generally slower than a simple linear search.
@jelewis2 True, although if you're in a situation where you're going to be doing multiple searches on the dataset, it's probably worth the time to sort it once so you can perform binary searches.
great video guys :) while your other topics might not hit me as hard, your algorithms videos are just great, really been looking for tutorials like these. so great job :)
This has been flagged as spam show
Thanks, It helps me lot
agarwalyeshu 13 hours ago
This explained to me in a few minutes what my professors been yapping to us for the past 2 weeks. Your a life saver!
teknoboy420 4 days ago
OMG perfect I totally needed that!!! :)
oOSue 2 weeks ago
Comment removed
oOSue 2 weeks ago
thanks...
very helping... :D
indrawanhalim 1 month ago 2
Where did the background music come from; it sounds very nice.
PSRChr1 2 months ago
This has been flagged as spam show
Hi! Could you guys please check out my channel? I will do a giveaway when I reach 100 subscribers! Thanks!
hackster2011 3 months ago
This has been flagged as spam show
Hi! Could you guys please check out my channel? I will do a giveaway when I reach 100 subscribers! Thanks!
hackster2011 3 months ago
if its in C++ why do we need a size... aray.size()?
falconmick 5 months ago
2:03 if its less or equal? with a single code line you can check if its equal and only continue if its less, no need to search any longer if it is equal, but still great tutorial
TearsofMandos 10 months ago
This has been flagged as spam show
The pseudo-code you provided does not work for finding the last element in the array. The simple fix for this is to add an else if statement after the if( A[low] == target ) statement checking for the value at A[high]. Here is the code you would add: else if ( A[high] == target ) { return high; }
protosspc 10 months ago
Comment removed
protosspc 10 months ago
Thanks. Extremely helpful.
ddopeski 11 months ago
you will also have to sort the binary array so that adds a lot of time well to the computer a lot of time.
Nick28th 1 year ago
Excellent video, very understandable.
ubermench42 1 year ago
good job with the thorough explanation.
locksndoors 1 year ago
Love your videos man. I got a programming test tomorrow u helped me alot! Cheers!
Edange 1 year ago
THNX :)
aashish387 1 year ago
This has been flagged as spam show
there are many datig side for you naneedj.info
shakira20848 1 year ago
@MrDavidVuong I thought that at first, but think about it; that means one more test at every single step, so a 50% increase in time at each step; you're trading a potentially reduction in the number of steps, for an increase in the time each step takes. For more than a relatively tiny dataset, you're better not performing the equals test.
aawood 1 year ago
danke! :D
undo4peace 1 year ago
i hate binary and linear search over any other algorithms
lthindu 2 years ago
the best!
sinokayaako 2 years ago 3
really nice tutorial,but it will better if you will post an shortest path algorithm:P.
SergiuXxCracker 2 years ago 20
It's unfortunate that linear searches are sometimes needed, because the fastest known sorting algorithms are slower than O(n) in the average case, so sorting followed by a binary search is generally slower than a simple linear search.
jelewis2 2 years ago
@jelewis2 True, although if you're in a situation where you're going to be doing multiple searches on the dataset, it's probably worth the time to sort it once so you can perform binary searches.
aawood 1 year ago
great video guys :) while your other topics might not hit me as hard, your algorithms videos are just great, really been looking for tutorials like these. so great job :)
psychofish25 2 years ago 4
Awesome !
OlloX3 2 years ago 3
Thanks dude really good.
zamliman 2 years ago 30