Upload
hout300
View
356
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
Start
Search Item
Set index to 1
Set found to false
While not found and not end of
array
If item = search
Found = true
If true
Item output found
Item not found
Location = index
No Yes
Yes
YesNo
No
Linear SearchFlowchart
Start
Input item searching
for
Set found to false
Set bottom to 0
Set top to (MAX -1) elements
While bottom <=
top and not found
Middle = (bottom + top)/2
If list at middle =
itemFound = true
If list at middle <
item
Location = middle
Bottom = middle + 1
Top = middle - 1
If found = true
Output item was not found
Output location
item found Stop
Yes
No
YesYes
Yes
No
Yes
No