Binary Search Algorithm | C Programming Example

  Рет қаралды 59,502

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 86
@parinrava978
@parinrava978 Жыл бұрын
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.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I’m glad you enjoy the videos, thank you so much for leaving this nice comment and good luck on your midterm! :-)
@aditopguy9785
@aditopguy9785 Жыл бұрын
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
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re very welcome, I’m glad you’re enjoying the explanations! :-)
@TSkateT666
@TSkateT666 2 жыл бұрын
have an exam soon in "Introduction to C" course in uni, this really helped alot!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Awesome, I’m glad to hear it was helpful! And good luck on your exam! :-D
@eugeneplay9416
@eugeneplay9416 2 жыл бұрын
Love your videos. Really easy to follow along and very good explanations.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you very much Eugene, I'm glad to hear you enjoy the videos! :-D
@ostryy0560
@ostryy0560 2 жыл бұрын
Thanks my man. I am preparing for a test, and this video helped me AF. Greetings from PL 🇵🇱
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
That's awesome I'm glad to hear it helped you out! And good luck on that test! :-)
@mongraal2272
@mongraal2272 2 жыл бұрын
Thaaaaank you...i I watched this video for 3 hours and i finally understood...thank u,ur logic is so impressive
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re welcome, I’m glad you figured it out! :-)
@elfullin
@elfullin 6 ай бұрын
I like that you used recursive methods. Thank you
@Mnogojazyk
@Mnogojazyk 2 жыл бұрын
Love your videos. Finally do I understand the concepts! Many thanks!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re very welcome! :-D
@SouvikMandal-tl2to
@SouvikMandal-tl2to 6 ай бұрын
a better breaking condition for the binary search would be if(l == r) rather than if(l>r) i think !
@nazaraljendli9758
@nazaraljendli9758 2 жыл бұрын
best c tutorials out there thank you
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome Nazar! 😀 And thank you very much for the positive feedback too.
@pvcksubhashini4984
@pvcksubhashini4984 2 жыл бұрын
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!!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
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: kzbin.info/aero/PLA1FTfKBAEX6BdpNaWp2uw-YspHwY7qwW
@pvcksubhashini4984
@pvcksubhashini4984 2 жыл бұрын
@@PortfolioCourses Ya i saw that one also I shared to my friends too. Thanks for the Content ☺
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
It's interesting, but I'm not sure KZbin will allow me to "re-generate" the subtitles as English. I may need to upload my own or something, what a pain!
@johnofalltrades2000
@johnofalltrades2000 Жыл бұрын
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.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
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: kzbin.info/www/bejne/gH-peKmgdrmCi6M
@johnofalltrades2000
@johnofalltrades2000 Жыл бұрын
@@PortfolioCourses oh I see now, what a silly mistake. thank you so much for clarifying it for me.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
No problem! :-)
@FeroLight-e2n
@FeroLight-e2n Жыл бұрын
That was amazing .Thank you
@omatzi7251
@omatzi7251 Жыл бұрын
Great video and great teacher!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
I’m glad you enjoyed the video and teaching! :-)
@juanmacias5922
@juanmacias5922 2 жыл бұрын
Great video! Explained super well!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
I’m glad you enjoyed it Juan! :-
@veggieveggie1215
@veggieveggie1215 8 ай бұрын
what microphone do you use?
@loser22-q7w
@loser22-q7w Ай бұрын
isnt it reasonable to use the sizeof function to find the midpoint?
@germankoga8640
@germankoga8640 5 ай бұрын
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?
@epicgameryt4052
@epicgameryt4052 Жыл бұрын
You're actually kinda awesome, thanks!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Aww thank you so much, I really appreciate that! :-)
@bieelzzin
@bieelzzin Жыл бұрын
Thank you! Perfect explained
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome Gabriel, I'm glad you enjoyed it! :-)
@OumaamarIsra
@OumaamarIsra 6 ай бұрын
Thank you man you save my life
@magdugalrexon7234
@magdugalrexon7234 2 жыл бұрын
Thank you for the video. It was really helpful.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome! I'm glad to hear it was helpful for you. :-D
@loginashaalan2826
@loginashaalan2826 6 ай бұрын
what if the value needed is less than all the elements of the array does we do the same as return -1?
@RelAxGamingKing77
@RelAxGamingKing77 2 жыл бұрын
Thank you so much, really helped me out!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're very welcome, I'm glad to hear it helped you out! :-D
@athunasos1649
@athunasos1649 11 ай бұрын
Using a loop is more memory efficient than using a recursive function
@DeadPool-jr2er
@DeadPool-jr2er 2 жыл бұрын
I love it!! Thank you!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're very welcome! :-)
@adamsetterberg5223
@adamsetterberg5223 2 жыл бұрын
Love the video!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
This number guessing game might be close to what you're looking for: kzbin.info/www/bejne/amKxnpaddpZ7fJI 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
@adamsetterberg5223
@adamsetterberg5223 2 жыл бұрын
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?
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
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: kzbin.info/www/bejne/iquap3Wlmb-kpZo Selection Sort: kzbin.info/www/bejne/j5bTe2qcedKsoKs Quicksort: kzbin.info/www/bejne/ZpunmnWDa52Bfbc Merge Sort: kzbin.info/www/bejne/gpa6pp6fbKaEgtE
@erennkose
@erennkose 2 жыл бұрын
bro thank you so much
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome Aaron! :-)
@Code-nv8xl
@Code-nv8xl 10 ай бұрын
Why you didn't use that unsorted array searching :/
@elfullin
@elfullin 6 ай бұрын
Because you can’t use binary search on an unsorted array.
@emeziekejedidiah5547
@emeziekejedidiah5547 2 жыл бұрын
This video is great
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Thank you! Very glad to hear you enjoyed it! :-D
@dabawocks1121
@dabawocks1121 2 жыл бұрын
Thank you for this
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome! :-D
@maven5463
@maven5463 2 жыл бұрын
Hmm, Can't we just write mid = (l + r) / 2 🤔
@PortfolioCourses
@PortfolioCourses 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.
@maven5463
@maven5463 2 жыл бұрын
@@PortfolioCourses oh, understood now. The video was so helpful! 😄 Thank you.
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re welcome! :-)
@CSstudent_1001
@CSstudent_1001 Жыл бұрын
Thank u a lot 🌸
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Your very welcome! :-)
@idanmariani8601
@idanmariani8601 2 жыл бұрын
your awsome :)
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Aww thank you Idan! :-)
@haniforange
@haniforange 10 ай бұрын
2 hours before final exam wish me luck
@PortfolioCourses
@PortfolioCourses 10 ай бұрын
Good luck! :-)
@duck_roster
@duck_roster 10 ай бұрын
Lol sameeee 🫣
@softvampir3
@softvampir3 6 ай бұрын
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.
@PortfolioCourses
@PortfolioCourses 6 ай бұрын
The video does have auto subtitles, you just have to click the gear icon in the top-right to enable them. :-)
@softvampir3
@softvampir3 6 ай бұрын
@@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".
@PortfolioCourses
@PortfolioCourses 6 ай бұрын
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.
@SurajBhandari-px1rv
@SurajBhandari-px1rv 6 ай бұрын
​@@PortfolioCoursesIts not available in my device too
@PortfolioCourses
@PortfolioCourses 6 ай бұрын
What type of device are you using?
@Aaron-hh8nx
@Aaron-hh8nx Жыл бұрын
#include using namespace std; int main() { int LIST[25],MAX; int FIRST, LAST, MIDDLE, I, ITEM, LOC=-1; coutMAX; cout
@PortfolioCourses
@PortfolioCourses Жыл бұрын
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.
@Aaron-hh8nx
@Aaron-hh8nx Жыл бұрын
@@PortfolioCourses please do, it's from my school text book
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Cool! :-)
Quicksort Algorithm Implementation | C Programming Example
20:37
Portfolio Courses
Рет қаралды 64 М.
Learn Binary Search in 10 minutes 🪓
10:04
Bro Code
Рет қаралды 125 М.
Turn Off the Vacum And Sit Back and Laugh 🤣
00:34
SKITSFUL
Рет қаралды 7 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 9 МЛН
Why no RONALDO?! 🤔⚽️
00:28
Celine Dept
Рет қаралды 86 МЛН
Merge Sort | C Programming Example
18:02
Portfolio Courses
Рет қаралды 86 М.
2.6.1 Binary Search Iterative Method
19:36
Abdul Bari
Рет қаралды 838 М.
Binary Search Algorithm in C#
17:06
Milan Jovanović
Рет қаралды 7 М.
C++ Programming: Linear Search Algorithm
14:14
ReelLearning
Рет қаралды 176 М.
C++ Programming: Binary Search Algorithm
14:53
ReelLearning
Рет қаралды 222 М.
you will never ask about pointers again after watching this video
8:03
Why is Python 150X slower than C?
10:45
Mehul - Codedamn
Рет қаралды 17 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 835 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Introduction to Binary Search
16:25
Lalitha Natraj
Рет қаралды 159 М.
Turn Off the Vacum And Sit Back and Laugh 🤣
00:34
SKITSFUL
Рет қаралды 7 МЛН