Question
Recall the problem of finding local minimum in an array. An element is a local miniimum if it is less than the element to its
Recall the problem of finding local minimum in an array. An element is a local miniimum if it is less than the element to its immediate left as well as less than the element to its immediate right. That is, we say the element A[i] at index i is a local minimum only if A[i] < A[i-1] and A[i] < A[i+1]. In this sense, an array A[0...n-1] can possibly have local minimum only at index values 1, ..., n-2 and not at indexes 0 and n-1
Pre-requisites for an array to have at least one local minimum:
1. The arary should have at least 3 elements
2. The first two elements of the array should be decreasing and the last two elements of the array should be increasing
3. The array should have distinct elements
So for this question:
a) Given the tabove three pre-requisites provide a pseudo code to find a local minimum in the array (it is sufficient to find just one local minimum in the array).
b) Create an array of 10 distinct integers that also satisfies the other two pre-requisites as listed above and show the execution of your pseudo code.
Please be as detailed, easy to read, and organized as possible. Also, pseudo code should be in Java if it resembles anything. Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started