Question: ( 1 5 points ) Jujutsu High has 3 freshmen, Yuji Itadori, Magumi Fusigoro, and Nobara Kugisaki. They are assigned a list of tasks they
points Jujutsu High has freshmen, Yuji Itadori, Magumi Fusigoro, and Nobara Kugisaki. They are assigned a list of tasks they must finish together. Each task has a unique ID However, each has a weird way of choosing their task from the remaining tasks in the list.
Yuji Itadori: Always chooses the tasks with the max or min ID Min or Max is decided randomly by him assume probability for each min or max
Megumi Fusigoro: He will choose a k and call the kth smallest ID Kth ID when all IDs are arranged in ascending order is chosen randomly from the total tasks available in the list Total tasks
Nobara Kugisaki: He will always choose the median ID If there are tasks in the list, the median will be defined as take floor valueth ID when all of them are arranged in ascending order. For both odd and even
Page
Sataru Gojo wants to digitize this process of choosing tasks and is asking for your suggestions on the data structure that would be ideal for this scenario. Your task is to design a data structure that supports the query of each of the three freshmen. The data structure should be highly efficient. It should return the task ID in for all scenarios.
Note: Once the task is assigned to someone, it can't be reassigned to someone else. It must be deleted from your data structure. Taking input elements, setting them in your data structure can take or but query execution should be in
Input example: a list of unique task IDs and query or Return the task ID for the corresponding candidate.
Input Query:
Output: Max element, is no longer available in the list after query
Input Query:
Enter k:
Output: rd smallest in the list.
Input Query:
Output: Initial length was ; after removing elements, the new length is median So the nd smallest element is
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
