Question: Write a C program for the following problem. Suppose an array A has n distinct integers. Write an algorithm to find an index k (k

Write a C program for the following problem. Suppose an array A has n distinct integers. Write an algorithm to find an index k (k need not exist/ need not be unique) such that A[O].......... .... A[k] is an increasing sequence and A[k+1}....... A(n-1) is a decreasing sequence. Examples: A = {5,4,3, 2, 1} Here k=0, A[O] is an increasing sequence and A[1,4] = {4,3,2,1) is decreasing. = A = {2,4,6,5,2,1} then k can be 1 or 2. A = {1,3,5,4,6,2} k does not exist = Note: Read how many numbers and numbers in the array. Print k value if found or else print 'k does not exist' For example: Input Result 5 0 5 4 3 2 1 6 k does not exist 1 3 5 4 62
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
