Question
Question # 2 ( Proper solution Required) An array of n integers x1, x2, . . . , xn is known to have the following
Question # 2 (Proper solution Required)
An array of n integers x1, x2, . . . , xn is known to have the following property: elements follow in ascending order up to a certain index p where 1 < p < n, then there are several equal entries up to a certain index q, where p < q < n and then follow in descending order: x1 < x2 < . . . < xp1 < xp = xp+1 . . . = xq > xq+1 > . . . > xn. Give an efficient algorithm to find the indices p and q. Note: the worst case running time of your algorithm must be in o(n), so simple scanning from left to right will get 0 marks. Detailed pseudocode along with the brief description of main idea and justification of correctness is required for full mark in this question.
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