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
What are the uses of secondary indexes?
What is runtime analysis?
In select-options, how to get the default values as current month first date and last date by default?
In which time constraint does the infotype records depend on the subtype ? : abap hr
What is open sql vs native sql ?
Explain how do you use structures in the abap programs?
java script for push button in adobe forms.
What are the system fields?
What is an authorization in sap?
What is payroll area
1. If I send 5 entries of table from one system to another system, if the only 4 entries there in the target system what I have to do? 2. If I send the customer master IDOC from one SAP system to another system, if one field is missing in target table what is the steps? 3. If I want to access the 4th row 3rd column in the hashed table how to do it? 4. Whether there is any other statement than MODIFY statement to modify the content of internal table?
What are the types of indexes in abap?
What are the different methods of passing data? : abap modularization
What are the objects of the abap dictionary or what types of objects can be created in the abap dictionary? : abap data dictionary
Why do we use Abstract classes give an example from your project?