Question: 1. Consider the following sorting algorithm: ALGORITHM INPUT: array a OUTPUT: sorted array a Find the smallest element in the tail of the array ali

1. Consider the following sorting algorithm: ALGORITHM INPUT: array a OUTPUT: sorted array a Find the smallest element in the tail of the array ali n], call it alj] Swap it with a [0], if it is smaller than a[O] Repeat this process with index 1, 2, until the whole array is sorted. (a) Write pseudocode for the given algorithm. (h) Program your pseudo(ode and attach it to this assigillient (Java. Pythonor C++, only (c) Give the best-case and worst-case running times of sort in e-notation. 2. (a) Write a recursive algorithm with worst-case running time O(log n) and best-case running time O(1) that scarches a sorted array for a given element and either returns the index of the element or -1 if it is not found in the array (b) Give the pseudocode for the algorithm in part (a). (e) Program your psendocode and attach t to this assignment (Java, Python, or C++, only (d) Prove that your algorithm meets the efficiency considerations described in part (a)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
