Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In an alternate reality, the 4 1 7 staff are deciding where to travel to escape from their weekly duties. Robbie really wants to go
In an alternate reality, the staff are deciding where to travel to escape from their weekly duties. Robbie really
wants to go to Chicago but hes willing to change his mind, provided that more than of the TAs can agree on a
different place. Before starting the discussion, every TA writes up a Location Proposal detailing their ideal travel
spot.
If more than of the TAs agree exactly on what place to visit, then Robbie is out of luck.
Otherwise, the staff will travel to Chicago.
More formally, you have an array of n Locations called proposals You can call equals on two Locations, but
it takes a long time. Even worse, theres no compareTo implemented, nor a hashcode So you cant sort these
Objects, nor put them in a hash table.
In the case that more than of the TAs submit equal Location Proposals, you should return that Location.
Otherwise, you should return Location.RobbieFavorite.
In this problem, youll describe a divideandconquer algorithm that requires O t n log n time.
For simplicity, you may assume that the number of elements in the array is a power of
a Write pseudocode or English for your algorithm. Your algorithm must use divide and conquer. There are
other possibly more efficient algorithms that arent divide and conquer, but they are not permitted for this
question we want you to practice the new technique
b Prove the following implication: If more than of the TAs agree on a location, then in at least one of the
two subarrays more than of the TAs agree on a location. For simplicity, you may assume the number of
elements is a multiple of
c Write a recurrence to describe the running time of your algorithm. When analyzing running time, assume that
any call to equals will take t time. You should treat t as a variable in your runningtime analysis of this
problem ie dont consider it a constant and have it disappear in the Onotation Briefly sentences
justify your recurrence. You should convince yourself that the running time will be O t n log n but you
dont have to include that explanation.
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