This preview shows page 1. Sign up to view the full content.
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 ﬁnds 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
 Spring '14
 M.Nojoumian
 Algorithms, Sort

Click to edit the document details