Answered step by step
Verified Expert Solution
Question
1 Approved Answer
As an elephant trainer you are taking part in a international elephant exhibition. During the event elephants from different teams enter and exit the
As an elephant trainer you are taking part in a international elephant exhibition. During the event elephants from different teams enter and exit the show room - where elephant experts can inspect and score them. Elephants do not enter the show room all at once, as that would cause too much commotion. The organizers of the event are letting them in and out based on a predefined schedule. Before the show starts you get access to the schedule for your elephants - but not for the others. Nevertheless, during the show, you can observe all elephants getting in and out of the room. Based on your experience, you believe that judges tend to award the biggest elephants in the room with the highest scores. Before the final results are out, you want to estimate your chances of winning this competition. Problem Statement Complete the following functions in the editor below: The ElephantCompetition class constructor that accepts elephant descriptions and the private schedule of when the elephants enter and exit the show room. The elephantEntered and elephantLeft functions that are called whenever a new elephant enters or leaves the room. The getBiggestElephants function that, for the current time, returns a list of our elephants in the room that are at least as big as the biggest elephant from competing teams in the room. The presented list has to be sorted alphabetically. Function Definitions The ElephantCompetition class constructor has the following parameters: elephants: a list of elephant descriptions each of which contains a name (a string) and a height (an integer) schedule: a list of elephant schedules each of which contains a name (a string), an enter time (an integer) and an exit time (an integer) - the enter and exit times are in minutes since the start of the show The elephantEntered function has the following parameters: currentTime: an integer which is the number of minutes since the start of the show height. an integer describing the height of the elephant that entered the room The elephantLeft function has the following parameters: currentTime: an integer which is the number of minutes since the start of the show height: an integer describing the height of the elephant that left the room Function Definitions The ElephantCompetition class constructor has the following parameters: elephants: a list of elephant descriptions each of which contains a name (a string) and a height (an integer) schedule: a list of elephant schedules each of which contains a name (a string), an enter time (an integer) and an exit time (an integer) - the enter and exit times are in minutes since the start of the show The elephantEntered function has the following parameters: currentTime: an integer which is the number of minutes since the start of the show height: an integer describing the height of the elephant that entered the room The elephantLeft function has the following parameters: currentTime: an integer which is the number of minutes since the start of the show height: an integer describing the height of the elephant that left the room The getBiggestElephants function has no parameters. Constraints Elephant names are unique The schedule is strictly followed - your elephants enter and exit the room exactly at the specified times Times (e.g., currentTime and the elephant enter and exit times) are always whole numbers and multiple events can occur at the same time The elephantEntered and elephantLeft are called in order of currentTime Each elephant enters the room only once during the show When the getBiggestElephants function is called at time teither o all the elephants that are scheduled to enter or leave the room at time thave not yet done so; OR o all the elephants that are scheduled to enter or leave the room at time thave done so.
Step by Step Solution
★★★★★
3.49 Rating (159 Votes )
There are 3 Steps involved in it
Step: 1
Steps Step 1 of 1 Heres the complete implementation of the ElephantCompetition class with the constructor elephantEntered elephantLeft and getBiggestElephants functions filled out This implementation ...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