what is the difference b/w linear search and binary search?
(how can these search)
Answer Posted / jayati saha
Linear search is ver easy and always search in sequential
way.
It starts searching from the first element upto the last
element until the search finds the number .
Let us take an example.
Let there are a list of numbers.
1,3,8,6,5,8,2,9
We have to search if 5 is there in the list or not.
So, we start from the first element from 1.
then we see 3,8,6 and then find 5.
As soon as we find the search element 5 in the list we stop
searching,otherwise we continue the search upto the last
element.
Binary search
In binary search we always start from the middle elment and
compare the middle element to the search element.
If the search element is less than the middle element then
we go to the less half otherwise we go to the larger half.
In binary search the nos should be sorted in ascending
order at first.
Let us took an example of binary search.
Assume that we are reading a book.
The book has a huge volume.
let we have to find the page no 120 in this book.
The book has 200 pages approx.
Then we do not start looking for the page from the first
page, rather we look at the middle.
If the arbitrary page is 101 then we think that 120 paghe
is more than the 101 page so we go to the half which
contains more pages. So by using this method again and
again we can finally find out the page .
| Is This Answer Correct ? | 86 Yes | 8 No |
Post New Answer View All Answers
What is netweaver???what is the relationship with ABAP?
Hi, I have a requirement for locking the fax field in user master records. As you know user can edit the details using the System>profile>own data (SU3), it is causing some security threat to our model. What i want is users should not be able to change the fax field under communications when they get into su3.I have heard of user Exist functionality but don't know how to implement it. Can you suggest something, it will be greatly appreciated.
What are ranges?
What are the different types of abap/4 programs?
What is exception class and test class. How to use it?
What is meant by payscale structure? How did you configure pay scale structure? : sap abap hr
How is time management and payroll is integrated? : sap abap hr
Difference between open sql and native sql? : abap data dictionary
Explain the differences between at selection-screen and at selection-screen output?
What are the different types of luws. What are they?
What are the steps in a bdc session? : abap bdc
What are the two ways for restricting the value range for a domain ?
What are the two levels in defining a match code ?
Is it possible to pass data to and from include programs explicitly?
Explain the structure of a bdc sessions?