BINARY SORT
BINARY SEARCH:-
ALGORITHM:-
STEP 1. SET BEG:=LB,END:=UB AND MID =INT(BEG+END)/2)
STEP 2. REPEAT STEP 3 & 4 WHILE BEG<=END AND DATA[MID] is not equal to ITEM
STEP 3. IF ITEM <DATA[MID],THEN
SET END:=MID-1
ELSE
SET BEG:=MID+1
STEP 4. SET MID:= INT(BEG+END)/2
STEP 5. IF DATA [MID] =ITEM, THEN
SET LOC;=MID
ELSE
SET LOC:=NULL
STEP 6. EXIT
CODE:-
Comments
Post a Comment
Kaushikmadhav77@gmail.com