what is the difference b/w linear search and binary search?
(how can these search)

Answer Posted / amit kumar thakur

liner search -data is a linear array with (n)and item is
given this variable algorith find the location (loc)of item
in data. (linear search is used when the address is find)
(Aigorith)
step .1 [insert item at the end of data ]
set data [n+1]:=item
step. 2 set loc:=1
step.3 [search for item]
repeat while data [loc] is not equal to item
set loc :=loc+1
[end of loop]
step.4 if loc =n+1, then
set loc:=0
[end if]
step.5 EXIT.

Binary search
suppose data is an array which is store in increasing
numerical order .then there is a extremly effficient
searching called binary search .
which can be used to find the loc of a given item of
information in data.
e.g.
suppose one want to find the location of some name in a
telephone directory(or some word in a dictionry) then we
use the binary search not the linear search.
ALGORITH OF BINARY SEARCH.
STEP.1 SET BEG= LB, END=UB AND MID= INT.
STEP.2 BEG<=END AND DATA [MID]!ITEM
STEP.3 IF ITEM< DATA[MID], THEN:
set end:=mid-1
step.4 set mid=int[(beg+end)/2]
[end if]
step.5 EXIT.

Is This Answer Correct ?    11 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the different types of view?

607


What do you mean by pooled tables in sap abap? Also explain what do you mean by table pool? : abap data dictionary

555


What is meant by read lock? : sap abap data dictionary

565


Explain what is the difference between primary key and unique key?

644


How can we handle table control in bdc? : abap bdc

598






What are the different software packets available in the market? : sap abap hr

578


Difference between open sql and native sql? : abap data dictionary

612


What function does data dictionary perform?

573


When value table becomes check table?

582


What are the different types of parameters? How can you distinguish between different kinds of parameters?

548


What will happen when we use fully buffered in abap?

563


What is the meaning of client independent?

571


When a program is created and need to be transported to prodn does selection texts always go with it? If not how do you make sure? Can you change the cts entries? How do you do it?

572


How do you find out who has transported a transport request?

616


How many primary keys can be created for a table?

622