An implementation of the binary search algorithm in C. Source code: github.com/por.... Check out www.portfolioc... to build a portfolio that will impress employers!
I love your videos. I have a midterm tomorrow on uni course C programming and I have been watching many videos about this topic and nobody can describe it well like you do. I used to hate C cause I didn't understand anything but after watching your videos everything makes sense. It's very detailed and contains only information that we need to know in order to understand the concept. Thank you so much for great work.
Very Nice Content Useful to all Plz make subtitles in english (In this video Subtitiles r translating in dutch when converted to english it doesn't make sense) Plz make C++ also , u r explaining very nice!!
That's so weird that it auto-generated the subtitles to Dutch! Thank you for letting me know, I will see if there is anything I can to do fix that. :-) Also, I have now started a series of C++ videos as well: ua-cam.com/play/PLA1FTfKBAEX6BdpNaWp2uw-YspHwY7qwW.html
It's interesting, but I'm not sure UA-cam will allow me to "re-generate" the subtitles as English. I may need to upload my own or something, what a pain!
the mathematical operation presented in the line: int mid = l + (r - 1) / 2; doesn't work for me. My compiler seems to go out of memory bounds because of this. I've tried: int mid = (l + r) / 2; and it worked.
It should be: int mid = l + (r - l) / 2 So it's an l not a 1. It's more complicated, but it's actually better to do it this way instead of (l + r) /2, see this video: ua-cam.com/video/JNFGvjATOUA/v-deo.html
This number guessing game might be close to what you're looking for: ua-cam.com/video/41NmcgA1HF0/v-deo.html And to my knowledge we can't really use binary search on an unsorted array, unless we sort it first. Here are some folks explaining why: www.quora.com/Can-binary-search-be-applied-on-unsorted-list
Hello Again! I having a problem with binary searching...... So lets say that you tell you computer to "random generate" 10 numbers between 1 - 20. And you want to know if the number 7 have been generated. Do you need to bubble sort first before you use binary searching?
Yes, the list needs to be sorted before you can use binary search. You could use bubble sort, or you could use something like insertion sort, selection sort, quicksort, or merge sort. In terms of performance, for very small arrays like this, using insertion sort or selection sort would be best (better than bubble sort too). For larger arrays, using something like quicksort or merge sort would be better. We have videos on all these aglorithms too: Insertion Sort: ua-cam.com/video/Tz7vBodZqo8/v-deo.html Selection Sort: ua-cam.com/video/YepJ7fDmyjI/v-deo.html Quicksort: ua-cam.com/video/0jDiBM68NGU/v-deo.html Merge Sort: ua-cam.com/video/LeWuki7AQLo/v-deo.html
Great question! 😀 You could do it that way too, though what we do in this video is better in terms of preventing an integer overflow: stackoverflow.com/questions/25113506/why-m-l-r-l-2-instead-of-m-lr-2-avoid-overflow-in-c.
@@PortfolioCoursesNo actually when I click the gear icon I see: "Stable Volume" ; "Ambient Mode" ; "Playback speed" ; and "Quality" there is no closed captions or subtitles on the gear icon. Next to the gear icon on the left is "cc" button which is greyed out and when I hover over it the message reads -> "Subtitles/closed captions unavailable".
Weird, what type of device/software are you using? I'm using Firefox on MacOS. I'm thinking it could be a difference related to using web vs. app or something like that.
I love your videos. I have a midterm tomorrow on uni course C programming and I have been watching many videos about this topic and nobody can describe it well like you do. I used to hate C cause I didn't understand anything but after watching your videos everything makes sense. It's very detailed and contains only information that we need to know in order to understand the concept. Thank you so much for great work.
I’m glad you enjoy the videos, thank you so much for leaving this nice comment and good luck on your midterm! :-)
Thank you for putting in the time and effort to make these videos. You are explain concepts so well, way better than my university lecturer
You’re very welcome, I’m glad you’re enjoying the explanations! :-)
Love your videos. Really easy to follow along and very good explanations.
Thank you very much Eugene, I'm glad to hear you enjoy the videos! :-D
Thanks my man. I am preparing for a test, and this video helped me AF. Greetings from PL 🇵🇱
That's awesome I'm glad to hear it helped you out! And good luck on that test! :-)
have an exam soon in "Introduction to C" course in uni, this really helped alot!
Awesome, I’m glad to hear it was helpful! And good luck on your exam! :-D
I like that you used recursive methods. Thank you
Thaaaaank you...i I watched this video for 3 hours and i finally understood...thank u,ur logic is so impressive
You’re welcome, I’m glad you figured it out! :-)
a better breaking condition for the binary search would be if(l == r) rather than if(l>r) i think !
Love your videos. Finally do I understand the concepts! Many thanks!
You’re very welcome! :-D
That was amazing .Thank you
Very Nice Content Useful to all
Plz make subtitles in english (In this video Subtitiles r translating in dutch when converted to english it doesn't make sense)
Plz make C++ also , u r explaining very nice!!
That's so weird that it auto-generated the subtitles to Dutch! Thank you for letting me know, I will see if there is anything I can to do fix that. :-) Also, I have now started a series of C++ videos as well: ua-cam.com/play/PLA1FTfKBAEX6BdpNaWp2uw-YspHwY7qwW.html
@@PortfolioCourses Ya i saw that one also I shared to my friends too. Thanks for the Content ☺
It's interesting, but I'm not sure UA-cam will allow me to "re-generate" the subtitles as English. I may need to upload my own or something, what a pain!
best c tutorials out there thank you
You're welcome Nazar! 😀 And thank you very much for the positive feedback too.
Great video! Explained super well!
I’m glad you enjoyed it Juan! :-
Thank you man you save my life
Thank you! Perfect explained
You're welcome Gabriel, I'm glad you enjoyed it! :-)
I didn't understand how you calculated mid, wouldn't you have to sum the two extremes and divided them by 2 to find the mid point?
the mathematical operation presented in the line:
int mid = l + (r - 1) / 2;
doesn't work for me. My compiler seems to go out of memory bounds because of this.
I've tried:
int mid = (l + r) / 2;
and it worked.
It should be: int mid = l + (r - l) / 2
So it's an l not a 1.
It's more complicated, but it's actually better to do it this way instead of (l + r) /2, see this video: ua-cam.com/video/JNFGvjATOUA/v-deo.html
@@PortfolioCourses oh I see now, what a silly mistake. thank you so much for clarifying it for me.
No problem! :-)
Great video and great teacher!
I’m glad you enjoyed the video and teaching! :-)
You're actually kinda awesome, thanks!
Aww thank you so much, I really appreciate that! :-)
Using a loop is more memory efficient than using a recursive function
what microphone do you use?
Thank you for the video. It was really helpful.
You're welcome! I'm glad to hear it was helpful for you. :-D
Thank you so much, really helped me out!
You're very welcome, I'm glad to hear it helped you out! :-D
isnt it reasonable to use the sizeof function to find the midpoint?
Love the video!
This number guessing game might be close to what you're looking for: ua-cam.com/video/41NmcgA1HF0/v-deo.html
And to my knowledge we can't really use binary search on an unsorted array, unless we sort it first. Here are some folks explaining why: www.quora.com/Can-binary-search-be-applied-on-unsorted-list
I love it!! Thank you!
You're very welcome! :-)
what if the value needed is less than all the elements of the array does we do the same as return -1?
Hello Again!
I having a problem with binary searching......
So lets say that you tell you computer to "random generate" 10 numbers between 1 - 20.
And you want to know if the number 7 have been generated.
Do you need to bubble sort first before you use binary searching?
Yes, the list needs to be sorted before you can use binary search. You could use bubble sort, or you could use something like insertion sort, selection sort, quicksort, or merge sort.
In terms of performance, for very small arrays like this, using insertion sort or selection sort would be best (better than bubble sort too). For larger arrays, using something like quicksort or merge sort would be better.
We have videos on all these aglorithms too:
Insertion Sort: ua-cam.com/video/Tz7vBodZqo8/v-deo.html
Selection Sort: ua-cam.com/video/YepJ7fDmyjI/v-deo.html
Quicksort: ua-cam.com/video/0jDiBM68NGU/v-deo.html
Merge Sort: ua-cam.com/video/LeWuki7AQLo/v-deo.html
Thank you for this
You're welcome! :-D
Thank u a lot 🌸
Your very welcome! :-)
This video is great
Thank you! Very glad to hear you enjoyed it! :-D
bro thank you so much
You're welcome Aaron! :-)
Why you didn't use that unsorted array searching :/
Because you can’t use binary search on an unsorted array.
Hmm, Can't we just write mid = (l + r) / 2 🤔
Great question! 😀 You could do it that way too, though what we do in this video is better in terms of preventing an integer overflow: stackoverflow.com/questions/25113506/why-m-l-r-l-2-instead-of-m-lr-2-avoid-overflow-in-c.
@@PortfolioCourses oh, understood now. The video was so helpful! 😄 Thank you.
You’re welcome! :-)
your awsome :)
Aww thank you Idan! :-)
2 hours before final exam wish me luck
Good luck! :-)
Lol sameeee 🫣
Watching this video for class - please please turn on subtitles at least auto subtitles it takes no work and saves many people who are watching.
The video does have auto subtitles, you just have to click the gear icon in the top-right to enable them. :-)
@@PortfolioCoursesNo actually when I click the gear icon I see: "Stable Volume" ; "Ambient Mode" ; "Playback speed" ; and "Quality" there is no closed captions or subtitles on the gear icon. Next to the gear icon on the left is "cc" button which is greyed out and when I hover over it the message reads -> "Subtitles/closed captions unavailable".
Weird, what type of device/software are you using? I'm using Firefox on MacOS. I'm thinking it could be a difference related to using web vs. app or something like that.
@@PortfolioCoursesIts not available in my device too
What type of device are you using?
#include
using namespace std;
int main()
{ int LIST[25],MAX;
int FIRST, LAST, MIDDLE, I, ITEM, LOC=-1;
coutMAX;
cout
That looks like the correct C++ solution to me. :-) Maybe I should make a C++ version of this video too though, that would be fun.
@@PortfolioCourses please do, it's from my school text book
Cool! :-)