Unformatted text preview: interested in their relative order. Can a linear-time algorithm be found when k is a constant? If so give the algorithm. In either case, justify your answer. 4. Consider a set S of n ≥ 2 distinct numbers given in unsorted order. Give an algorithm to determine two distinct numbers x and y ( x ≠ y ) exist in the set S such that x-y ≤ w-z for all w , z ∈ S and w ≠ z . Your algorithm should run in O ( n log n ) time. 5. The input is d sequences of elements such that each sequence is already sorted, and there is a total of n elements. Design an O ( n log d ) algorithm to merge all the sequences into one sorted sequence. << Solutions in Class>>...
View Full Document
- Spring '09
- Algorithms, Complex number, Limit of a sequence