Question: Specify the steps of your algorithm. You don t have to formally prove your algorithm is correct, but it would be a good idea for
Specify the steps of your algorithm. You dont have to formally prove your
algorithm is correct, but it would be a good idea for you to do so using strong mathe
matical induction it would be good practice
Your algorithm must:
be a valid divide and conquer algorithm, where each recursive call processes a sub
list whose size is roughly half that of the given sub list,
return a valid popular element in the given input list for any valid input list,
use O additional space, not counting the implicit space used by the call stack
so just local variables, and no extra auxiliary data structures of any kind
not modify the given input list,
not use any repetition loop structures, and
have best case running time O
You may assume that Count x A al al ar returns the number of occurrences
of x in A and its worst case running time is Of N where N r l You must
use Count in your solution.
Ill get you started with certain parts of the algorithm, and you fill in the missing details.
Your algorithm must achieve best case running time O
PopularSortedA al al ar:
if l r then
end if
Let m lr
AL al al am and AR am am ar Give a general characterization of the the set of best case inputs for your PopularSorted algorithm, assuming N data.size State and justify its best case asymptotic running time of your Popular Sorted algorithm. Keep in mind that the requirements say that you must have O best case running time, but if you werent able to achieve this, then state the best case running time of your algorithm and justify it
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
