Question 1(27 marks) Consider the following problem. Given an array A consisting of n distinct integers A[1], ... A[n]. It is known that there is a position p (1≤ p Sn), such that A[1], .., A[p] is in increasing order and A[p], A[p+1],..., A[n] is in decreasing order. Write a brute force algorithm to find the position p. What is the time complexity of your algorithm? 2. Devise a "divide and conquer" algorithm to find the position p. 3. Set up a recurrence relation for the number of comparisons made by your algorithm and explain it. 4 Based on the recurrence relation, show the complexity of your algorithm in big-O notation and prove it using either the iterative method or the substitution method, i.e., Mathematical Induction (for simplicity, you can assume that n = 2*). 不要python写伪代码
1. Brute Force Algorithm to Find Position p
2. Divide and Conquer Algorithm to Find Position p
3. Recurrence Relation for the Number of Comparisons
4. Complexity of the Algorithm in Big-O Notation
Not the question you are looking for? Ask here!
Enter question by text
Enter question by image
Upgrade to Asksia Pro
Join a AskSia's Pro Plan, and get 24/7 AI tutoring for your reviews, assignments, quizzes and exam preps.