Data Structures and Algorithms course work. In pseudocode.
4 questions, as specified by lecturer about 20 minutes each. For professional programmer it should be easy job.
Here is 1st question:
"Let A be an array of n elements (tht is, the elements of A are A[0], . . . , A[n−1]).
An element A[i] is extreme if the following conditions hold regarding A[i].
• A[i] is not the first nor the last element of A. That is, 0 < i < n − 1.
• Either A[i − 1] < A[i] > A[i + 1] or A[i − 1] > A[i] < A[i + 1].
For example, the extreme points of an array [0, 5, 3, 6, 8, 7, 15, 9] are 5, 3, 8, 7, 15.
Please solve the following problems.
1. 20 marks. Write pseudocode of an algorithm that prints the extreme
points of the given array. If there are no extreme points, the algorithm
prints “SORTED”.
2. 5 marks. Is it always true that if an array has twoor more extreme
points, they alternate, like min-max-min-max-... or max-min-max-min-...
If you believethis is true, provide a short justification of your position.
Otherwise, provide an example of an array where the above pattern does
not hold"
Only reasonable offers.