Searching Algorithm Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Binary Search

A
SET found = false
input key
REPEAT
SET middle to (startpos+endpos) / 2
IF array(middle) = searchkey then
SET found to true
Output suitable message
ELSE
IF array(middle) < Search Key THEN
endpos = middle
ELSE
startPos = middle
END IF 
END IF
UNTIL found = true OR (startPos > endPos)
IF found = false THEN
output ‘not found’ message
END IF
How well did you know this?
1
Not at all
2
3
4
5
Perfectly