Csarmstrongedulianganimationbinarysearchanimationhtml

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: le (i ≤ n and x ≠ ai) i := i + 1 if i ≤ n then location := i else location := 0 return location http://www.cs.armstrong.edu/liang/animation/LinearSearchAnimation.html Binary Search —༉  Assume the input is a list of items in increasing order. —༉  The algorithm begins by comparing the element to be found with the middle element. If the middle element is lower, the search proceeds with the upper half of the list. b)  If the middle element is not lower, the search proceeds with the lower half of the list. a)  —༉  Repeat this process until we have a list of size 1. —༉  If the procedure finds the element in the list, the position is returned. —༉  Otherwise, 0 is returned to indicate that the element was not found. Binary Search —༉  Here is a description...
View Full Document

Ask a homework question - tutors are online