This preview shows page 1. Sign up to view the full content.
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
This note was uploaded on 04/28/2009 for the course CSC 226 taught by Professor Watkins during the Spring '08 term at N.C. State.
 Spring '08
 WATKINS

Click to edit the document details