Рет қаралды 19,438
We are learning about the searching algorithms in arrays. We have covered linear search algorithms in the last class and now we are going to learn about a very common and more effective search algorithm ie. Binary search.
Before moving to binary search, let's take a more practical example of search from our day to day lives.
How do you search for a number in a dictionary. Say you have to search success in a dictionary.
The linear search algorithm approach will be that you will start from will work starting with a and go in a sequential manner but surely it will take a lot of time and no one will do that.
We know that success start with s and hence we'll randomly attempt to open the dictionary and many we get c. Surely s is ahead of c and hence you will now search ahead of c.
The next time you may get t and hence you'll limit your search before t obviously.
What you are actually doing is shortening up the scope of search until you arrive at s and ultimately will find the word success.
This is what we need to do in a binary search. We need to shorten our scope of research with every attempt in a binary search algorithm.
Let's see how we can actually write a program to cover this binary search algorithm approach to search an element in an array in Java.
Watch the complete lecture to understand the binary search algorithm.
Subscribe to our channel for regular updates on the dsa course and click on the bell icon to never miss an update from our dsa course.
Data Structures and Algorithms Free Course (Learn DSA Without Paise) Playlist - • Data Structures And Al...
For more information, fill this form: forms.gle/8eiUmM92Fx563Aen9
or call us at 8884881203
Facebook: / thetapacademy
Instagram: / tapacademy_online
Linkedin: / 73820805
Website: www.thetapacademy.com
#dsa #dsacourse #java #dsainjava #javaprogramming #coding #coder #recursion #placement #array #arrayquestion #arrayjava