Linda creates an algorithm that takes an input sequence S andproduces an output sequence T that is a sorting of the n elementsof S.
a) In Java, give an algorithm, isSorted, for testing in O(n) timeif T is sorted.
b) Explain why the algorithm isSorted is not sufficient to prove aparticular output T of Linda’s algorithm is a sorting of S.
c) Describe what additional information Linda’s algorithm couldoutput so that her algorithm’s correctness could be established onany given S and T in O(n) time.
Answer
a) The following Java code is a simple test to check whether astring array sort function works
OR
OR