Use pseudocode to describe an algorithm that verifies whether an input sequence
a0, a1,..., an containing distinct elements is sorted or not. The algorithm returns 1 if the
sequence is sorted increasingly, returns 2 if the sequence is sorted decreasingly and
returns 0 if the sequence is not sorted.
Examples:
-3, 0, 2, 5, 6, 11, 25 ? returns 1
19, 15, 9, 2, -2, -4 ? returns 2
2, 3, 7, 12, 10, 11, 16 ? returns 0
a) How many comparisons is your algorithm performing in the worst, best and
average case as a function of n?
b) Use asymptotic notation to express the worst-case, best-case and average-case
running times obtained in point a.