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


Please Help Members By Posting Answers For Below Questions

What are the organizational related Infotypes

1786


What is a table cluster? : abap data dictionary

901


What is filter dependent BADI?

1143


What is the meaning of abap editor integrated with abap data dictionary? : abap data dictionary

901


How to display if the value entered contains records or not?

802


What will you code in start-of-selection & end-of-selection ?

817


What are the types of bdc s?

769


What is lock objects? : sap abap data dictionary

847


What is a matchcode?

799


what is bapi,badi,bdc,ale idocs?

1841


Explain the Inportance of pa30? : abap hr

997


What is the maximum number of match code id's that can be defined for one match code object? : abap data dictionary

815


What are system variable in abap?

814


Can there be more than 1 main window in sap script?

820


What are the uses of interactive reporting?

820