Question: JAVA Code. An array A, has the following n elements: k 1 ; k 2 ; ; k l ; q 1 ; q 2
JAVA Code. An array A, has the following n elements: k1; k2; ; kl; q1; q2; ; qm, where the sequence k1; k2; ; kl is monotonically increasing and the sequence kl ; q1; q2; ; qm is monotonically decreasing. Also, l + m = n and l is unknown. Present an O(log n) (hint: divide and conquer) time function FindTransition(A, 1, n) to determine l, not the element value, but its position. For example, if the input is 2; 5; 11; 24; 8; 1, the answer is l = 4. Please write a recursive JAVA code with O(log n) time complexity. Please add explanations for the steps, since I do not understand the question.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
