Question: Linda claims to have an algorithm that takes an input sequence S and produces an output sequence T that is a sorting of the n
Linda claims to have an algorithm that takes an input sequence S and produces an output sequence T that is a sorting of the n elements in S.
a. Give an algorithm, isSorted, that tests in O(n) time if T is sorted.
b. Explain why the algorithm isSorted is not sufficient to prove a particular output T to Linda’s algorithm is a sorting of S.
c. Describe what additional information Linda’s algorithm could output so that her algorithm’s correctness could be established on any given S and T in O(n) time.
Step by Step Solution
3.41 Rating (176 Votes )
There are 3 Steps involved in it
a i... View full answer
Get step-by-step solutions from verified subject matter experts
