Linda claims to have an algorithm that takes an input sequence S and produces an output sequence

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 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Data Structures and Algorithms in Java

ISBN: 978-1118771334

6th edition

Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser

Question Posted: