what is the difference b/w linear search and binary search?
(how can these search)
Answer Posted / asit kumsr tripathy
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 lower half otherwise we go to the upper 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 ? | 31 Yes | 2 No |
Post New Answer View All Answers
Why do we declare a method of a class final? What can be the purpose? Give a scenario.
What are the events in abap/4 language? : abap hr
What are the different types of data dictionary objects? : abap data dictionary
What are the steps to execute session method?
HI GUYS , FOR SAP INSTITUTION ATOS I BEST OR NOT? IAM PLANNING TO LEARN SAP COURSE IN ATOS... GIVE ME UR SUGGESTION ABOT ATOS?
What is the table buffer?
What is the difference between internal tables and extract datasets? : abap modularization
What is the difference between select statement and provide statement ? : abap hr
What are the client dependant objects in abap / sap?
List the various components of the enterprise structure in systems, applications, and products (sap) in human capital management (him)? : sap abap hr
Explain the advantages and disadvantages of abap query tool?
What application areas are you comfortable in?
in bdc session method. if u run the record in fore ground manually i have a 7 records but at the time of record processing first record produces the error how can u process records manually in fore ground please tell me any one knows?
Performance tuning techniques
What is the difference between scrolling a table horizontally and vertically?