Given an integer array a[o..n-1], please design an algorithm to output all the a[i] which satisfy…
Given an integer array a[o..n-1], please design an algorithm to output all the a[i] which satisfy: all the elements from a[0] to a[i] are larger than or equal to a[i], and all the elements from a[i] to a[n-1] are less than or equal to a[i] For example: a [0.4] = {32, 22, 19, 6, 10}; then output: 32, 22, 19 Assuming there are n elements in the integer array. Now the time complexity and space complexity of your algorithm are both restricted to o(n). Please design and implement an algorithm to solve this problem. Explain your idea first, and implement it using pseudocode Now we will see how prior knowledge about data distribution can allow us to achieve a faster sorting algorithm. Assume for the given integer array a[o..n-1], all the integers a[i], 0 lessthanorequalto I lessthanorequalto n-1, are in the range [0..99]. Please design and implement a sorting algorithm to sort the integer array, whose time complexity is restricted to 0(n) Explain your idea first, and implement it either using Java, C/C++ code or pseudocode.