Unformatted text preview: At each stage, i and j are compared using i < j to see if there is more than one term present. Two comparisons are used when there are 2k elements, two more when there are + 2k 1 elements, and so on until two comparisons are used when the are = 21 2 elements left. Finally when one term is left, two more comparisons are made, one to compare i and j and the other to determine if the term is x. At most there are 2k + 2 = 2*log(n)+2 comparisons which is O(log n)....
View Full Document
- Spring '08
- Negative and non-negative numbers, Fn+ Fn