Binary Search Algorithm - Theory + Code
Вставка
- Опубліковано 22 лип 2024
- This is the first video of a 2 part series on binary search. Here we discuss theory of the algorithm, compare it with linear search, derive the complexity, implement the code and cover order-agnostic binary search as well.
Take part in the learning in public initiative! Share your learnings on LinkedIn and Twitter with #DSAwithKunal & don't forget to tag us!
👉 Resources
- Join Replit: join.replit.com/kunal-kushwaha
- Complete Java DSA playlist: • Java + DSA + Interview...
- Code, Assignments, & Notes: github.com/kunal-kushwaha/DSA...
➡️ Connect with me: kunalkushwaha.com
=========================================
Timestamps:
0:00 Introduction
0:57 #DSAwithKunal
2:35 What is Binary Search?
7:20 Binary Search Algorithm
21:10 Why Binary Search?
29:21 Code for Binary Search
41:48 Order-Agnostic Binary Search
49:00 Code for Order-Agnostic Binary Search
57:42 Outro
#searching #placement #dsa #interviews
That's what I expected!
I already know binary search but knew that I will definitely learn something new from every video of this playlist. And guess what, I learned the improved version of binary search formula (start + (end - start) /2 ) !
Thanks a lot Kunal ❤😄
My pleasure!
@Mohit Same for me Folk..
same with me I know binary search but I never thought what if we don't know in which order array is sorted? Thanks, @ Kunal for such a good course.
Same bhaiii...Thanks kunal❤
I learn here some new concept like Order Agnostic Binary search before this I didn't hear the Agnostic Binary search 😂
As software engineer here in Seattle , I could tell you all this dude has an amazing content.
On my free time , instead of wasting my time on social media watching videos that don’t provide any value to me , I spend my whole time watching kunal as I am preparing to switch to MAANG this year.
Thanks a lot
"Binary Search made easy by kunal"
The Next Aditya Verma!!!
Almost everyone would ignore the debugging part,start+(end-start)/2,logN when they do teach Binary Search.However you stand apart from em!
Learning made easy and fun!
How Kunal make course- "complete dsa course"
How Ed tech mafia make courses -
Dsa for beginners
Dsa intermediate level
Dsa advance level
Dsa for FAANG
Dsa with c++
Dsa with Java
Dsa with python
Dsa in real life .
Dsa in 100 days.
Inshort it's their business to keep making courses otherwise what they will do if they make a single course.
Hope u r getting their strategy for non ending course making business.
Best Comment Ever! This is the absolute truth...
DSA toh DSA howe hai, chahe C++ ho ya GoLang. :P Love your content Kunal, while my peers are busy watching Money Hies i am spending my time here in your DSA playlist.
@@shomiksingh5929 😂😂dangal op🔥
You forgot "Master DSA in 5 Hours, Marathon Class" 😂😂😂😂😂
@@prakharagrawal7010 🤣🤣🤣
I turned off my adblocker, only to reward you for this amazing explanation kunal. Keep up the good work mate. Do share your payment details, I would love to help you. Thanks once again. ♥♥
I doesn't work like that
Were to get assignment answer code
I'm confused about assignments
Can any one explain
@@sayedhaneef6068 where to get answers
ans are available in leetcode itself@@funtrap2289
is it a pickup line bro?
This guy is on another level in terms of teaching method. You don't know kunal how much you are helping people learn these complex things in the easiest way possible. Thanks a lot. You deserve the world kunal.
# GOD Of DSA
Hi I am a 11yr exp java guy was searching for some free course on youtube for DSA came accross your course and i just feel love in it...all in one place that too with java...i must say you have done very awsome work...your name will be there on this earth as long as DSA will be asked in interviews...May Supream Lord Vishnu Bless You.. ✌🙏
Although I got to know about Ur channel just yesterday, But I wanna tell ki U r doing great man. Some people cannot ingest the fact that someone junior to him is also doing these things and getting that much audience. Its just hurting there ego, Nothing else.
Facts
Brother, I earnestly respect you & your hardwork that you're doing for us without any personal gains...Kudos to you bro😊💓👏
Thanks a ton
Help. I have doubt.
Unless we tell a function what to return, it wont return anything.
Then how does the Binary search know that it has to return the index of target.
I am posting this on random comments. If anyone knows the answer to this please comment.
@@jaynimje3790 At 37:20, you can see on line 12 that the return type of the function int.
This is how we tell the compiler that this function will return a value of type int.
I absolutely love how thorough you are in your explanations. This is the difference between you and also my professors from university. Most of the time they just give a very simple explanation without covering some details that are ESSENTIAL for understanding even the most basic algorithms. Thank you very much for helping me, I cannot wait to watch this entire playlist!
His continues efforts inspires us to do the same, literally!!!
These videos have helped me a lot this past month. Very grateful to Kunal for doing this, for helping students like us prepare for interviews. I am very eager for the upcoming videos and I hope you post them as soon as possible.
I'm actually short of words to praise this. I just wish that as a student i justify your hardwork . All the very best to you. Keep radiating goodness.
mid = start +(end -start)/2 blew away the problem I was facing in passing huge arrays.
Then came order-agnostic that compares start and end element to decide whether ascending or descending array🤯
Thanks Kunal, I'm enjoying this course🚀
Help. I have doubt.
Unless we tell a function what to return, it wont return anything.
Then how does the Binary search know that it has to return the index of target.
I am posting this on random comments. If anyone knows the answer to this please comment.
@@jaynimje3790 Brother, he is returning the mid and mid is that index. 😊
@@jaynimje3790 Our goal is to find and return the middle element only. The start and end pointers are just there to go left or right whenever the target element is less or greater than the middle element. If the target element isn't found, we will then return -1 instead of the index of the middle element. Hope this helps.
Instead of remembering mid = start +(end-start)/2 can't we do the same as mid = (start/2) + (end/2) ??
Kunal = EdTech Startup Killer 😂😂
I have only watched 3 videos of your DSA and I become your fan. Really excited to watch all your DSA videos.
This course will surely make me understand DSA in 2024👌
02/03/2024 - day 7 of learning DSA+JAVA
Where did you reach bro??
@@darkpunk9960 bro now I'm currently doing practice and trie, graph , ye nhi aata baaki ka thoda bahut aane laga hai
@@Mahak_Jainn thanks you keep doing!
Just love this episode of Binary Search.
Thank You so much for this series.
Hey Kunal !! This is the best course which I found in youtube and Now I started loving data structures your way of explaining each concept is outstanding. You are doing a great job. I have recommended this course to all my friends. Thanks alot for making such amazing videos.
It's my pleasure
Were to get assignment answer code
I'm confused about assignments
Can any one explain
Help. I have doubt.
Unless we tell a function what to return, it wont return anything.
Then how does the Binary search know that it has to return the index of target.
I am posting this on random comments. If anyone knows the answer to this please comment.
You do a great job in helping us understand concepts by thinking in inks. Thanks a whole lot Kunal for your charitable endeavors. Salute.
I have a bear minimum idea about java. I am so happy to watch this video. I didn't have any idea about binary search. The way you teach is amazing! Because I didn't feel I was watching 1 hr video.. I enjoyed learning about binary search. THANK YOU!
Thank you for clearing my all doubt about binary search as well as adding some extra knowledge about Binary Search.
hey kunal plz complete the DSA bootcamp you are the best teacher in the world.... i am waiting for your upcoming videos
Superb playlist on DSA. Learning so many things. Thank you!
I have seen a lot of videos to understand Binary Search also tried paid courses but I found this is the Best Video to understand Binary Search.
Lots of Love Kunal Bhai ❤
I am having 2 year exp in a good product company [not fang], still I am learning from your playlist everyday , and preparing for switch, thanks brother .
You can do it!
Anyone can learn with Kunal!! Extremely detailed and fairly explained! And that too for free ! Thanks a lot :) God bless you:)
Kunal bro your teaching style is awesome I watched your all video without skipping a single time
Best ever Java course Avaliable on UA-cam... I am addicted to learning Java
the way you found out the level k in the binary search is hust magic . so simple yet effective
I am from arts but keen to learn Programming. By gone through your videos really my curosity of learning coding is increasing doubly. All videos have the desire of getting awards. All are the best when comparing to other coding youtube videos. THANKS KUNAL BRO 😊
Thanks for the video Kunal! I knew about binary search but leant about agnostic binary search :). Last 90 seconds really pumped me up. Excited for the questions video 👍
Before watching your video, I thought these data structures are very difficult, after watched your video now I am getting confident I can also solve DS problems. Thank you Very much for your explanation.
Had my teacher explained the same way, I would have enjoyed Java.
Switched to Python. Now back to Java because of this course.
I'm enjoying java because of you.
Thanks a lot
Great to hear!
me too
You are doing the best. Hope you roll out other videos soon on tree, map and other important topics.
This is not just a video. Thank you very much for the valuable informations and lectures.
Explanation was wonderful!
A request, please don't stop Guidance and non-technical videos.
I dunno what happened but due to actions of some students, it would be unfair for all other thousand of students who need it.
he has given the best content, onto the next one, binary search is more clear now, thank you kunal
you are amazing kunal great contribution to community !!!
Thank you very very much Sir ......my search got end here after getting your video sir ......what an amazing, precise, all in complete one with full detail content you are providing sir....🙏🏻🙏🏻☀️🎊
Learning Data Structure has become very interesting and easy.....I am so much happy sir...🙏🏻🙏🏻
Thank you very much sir 🙏🏻🙏🏻💥🎉🎉
20:24, here boys, along with binary search , he taught us one more thing xD
Great tutorial btw
Good series for the community, easy to understand and without unnecessary masala...
you are awesome Kunal. First explanation then topic-based questions , this approach is a game-changer. Your teaching inspires us to learn more. This boot camp is gonna be a huge success.
Help. I have doubt.
Unless we tell a function what to return, it wont return anything.
Then how does the Binary search know that it has to return the index of target.
I am posting this on random comments. If anyone knows the answer to this please comment.
@@jaynimje3790
reason is we let
start = index 0
and end = index last not element at last so it return index
Kunal bhai is doing what legends do😍.
The Most Simplified Explanation Ever....🙌🙌🙌
THE PERFECT BINARY SEARCH VIDEO ON UA-cam 🔥 thanks kunal
I am completely shocked by the quality content that you provide Man!!!! Definitely going to share it with all my friends ..Thanks for providing it for free .Its much more than any paid course on any platform.
Help. I have doubt.
Unless we tell a function what to return, it wont return anything.
Then how does the Binary search know that it has to return the index of target.
I am posting this on random comments. If anyone knows the answer to this please comment.
@@jaynimje3790same doubt
@@jaynimje3790 Go and watch the previous videos in his playlist
DSA UA-cam playlist is Diamond, but GitHub link is Platinum so Overall thank you Kunal giving all of me a great material ❤❤
Thanks kunal for making such series of java course without any cost ❤
Never have I ever understood Binary Search better.
❤️ from KASHMIR!
I was not able to understand the concept of binary search in my college days but after seeing this video I was not only able to code the binary search program also did the order agnostic binary search without watching the code part thank you Kunal #DSAWithKunal
Hey Kunal, I am a first year student. I really enjoy java and have been doing it since 10th standard. I really love your videos man, you are my only mentor and I l really look up to you. I am already trying to improve my coding knowledge(First sem.), I really wish to become someone like you in the near future. Thanks a lot for being out there for students like me.
Hi
Now we Both on same year ...I really wanna like minded person in Java
Nice video,
good for all kind of students.
Must watch for BS
In this point 17:46 The Integer Value will be 5.
Most Appreciated Person @Kunal Kushwaha who make a DSA playlist like a Candy, once you start and you will not Stop..!!
Yaeh
Amazing kunal sir, I have recommended to all my colleague friends
Amazing Video, @kunal. Leaving this comment for the YT algorithm
sir, it's from from every one please complete the course we are waiting for your next videos and these videos are very helpful please sir complete the course
32:05 : why we use start+(end-start)/2 ? --> integer max value limit
48:30 : for checking whether array is ascending or descending in a sorted array just check first and last elements if all are equal the both also will be equal else there always is difrrence
I am short of words to praise this course .Thanks dear Kunal for providing us all quality education.
Glad to hear that
@@KunalKushwaha 🥹🫶🏻
Wow this is the real learning every bit of thr video is infused in my brains memory great work kunal bhaiya!!!!! ❤❤
Glad to hear that
Best lecture of Binary Search. I never learnt in this way.
wow!! so must crystal clear with the concepts best lectures for any basic programming
Kudos man... wow!... I enjoyed this lecture bro... CHEERS!... I learnt abount binary search nicely... keep going on bro...
Kunal kushwaha bhaiya you are the gem 💎 personality for many students ❤️❤️
Kunal the GOAT. I love your lecture man. You are life saviour for Juniors
I still don't know, why people are disliking these videos. These videos are like individual gem.
Superb explanation of Binary seach I have seen many videos of binary search like ending in just 7 to 8 minutes but this is out of the world.
Nice work.Waiting for next one
Glad you liked it!
Love you kunal, Thank you soo much!
Thanks a lot, Kunal Bhaiya for this amazing course.
Earlier I was not able to solve the questions on leetcode. But after starting with your course, I am able to solve easy-level questions.
Very excited for the question-solving videos !!!!
You are most welcome
Were to get assignment answer code
I'm confused about assignments
Can any one explain
One of the best binary search video i have ever seen, u explained it in very smooth way, waiting for ur further videos.
So nice of you
Thank You Kunal , I already knew binary search but didn't know the case where array was not in ascending order and now I learned something new ,thank you (:
Hats off man very well explained whole binary search 🎉🎉🎉
Thanks alot 🙌🙌🙌🙌🙌
Your point is very good that you explain even the smallest things. 🙌🙌
Glad it was helpful!
Still big fan on how you explain the train of thought to get to the solution and not just say it. So much easier to remember
Next Level Stuff !! Hats off !
You are doing a real noble work. Huge respect❤
After watching only 3 videos of yours I m like..... Yaar banda etna effort kr rha h aur etna sikhne ko mil rha h to like to krna bnta h... Pta nhi etne km likes kyun h jbki views to 37k show ho rha... Great work kunal
one of the best derivation of binary search time complexity i have ever seen!
You’re welcome
Not the next video, this video itself made me go WOW!! ♥️
Thank You again Kunal, such a wonderful lecture now I think how we we're taught, looking forward to your tree and graph videos.
You're most welcome
life would be easier if u are teaching every topic like these🌟
Very easy explanation Kunal! very excited to continue this course.
The way you explain is just on next level . You are Amazing keep it up Sir .❤️❤️
Help. I have doubt.
Unless we tell a function what to return, it wont return anything.
Then how does the Binary search know that it has to return the index of target.
I am posting this on random comments. If anyone knows the answer to this please comment.
Blessed to have such mentors in life
Since I'm an absolute beginner and started a little late, I'm having a hard time catching the pace of the course. But no worries, Aaram sey sab samajke karenge.
Yep do it on your own pace
same here
how to check if it is sorted if the array is something like this? arr = [1, 3, 6, 5, 8, 9, 12]. Eventhougn first and last numbers are sorted in the middle there are unsorted numbers?
Thank you soo much Bhaiya , I am learning first time Binary Search and trust me the concept is crystal clear 💚
Bhaiya mere laptop me debugging nahi horaha hai."Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended" ye dikha raha hai.Kya karu?
Such a great tutorial ❤️❤️❤️
waiting for yours upcoming tutorials.
Had Facing Time Limit Exceeded or Runtime Error At Many Binary Search Algorithms Problem but mid=start+(end-start)/2 helped me alot 🤩 Thankyou So Much Kunal
one of the best video, everyone teaches the same binary
but here : OMG
order agnostic/ proper dry run for time complexity
new way for finding the middle
thanks a lot
love ur videos u giving ur valuable knowlege simple way.excellent kunal!
superb explaination bhaiya thankyou so much for this playlist im from commerce bacground but only becoz of your explaination im able to understand the things how its working thanks alot kunal bhaiya .plz complete this playlist .
Just amazing Kunal really loved very helped in cllg and coding questions thanks
youre just amazing brother lots of love really you deserve a whole lot of respect ....thanks a lot 🌟
Just fell in love with the course❤
i love the expression you gave at 15:27 man attitude like thats it..... no more cycle this is beauty of dsa
Amazing video Kunal!!
Best explanation ever. Thank You Kunal.