Question: Problem 3 (20 points): Suppose you have a queue containing N unique numbers. Your task is to find the median of these numbers using only

 Problem 3 (20 points): Suppose you have a queue containing N

Problem 3 (20 points): Suppose you have a queue containing N unique numbers. Your task is to find the median of these numbers using only available queue operations (enqueue, dequeue, size, and isEmpty). Write down the steps using bullet points for solving this problem such that your pseudocode is easier to understand. Additionally, write a very high-level pseudocode and runtime analysis of your program. Note that your queue contents should be left unchanged after the execution. Your extra space usage should be 0(1), which means that you can only use variables in addition to the input queue (i.e., no extra arrays, queues, or any other data structure). Examples: Input Output Comment 1 2 3 4 5 6 7 4 Median is the middle number that would appear if you sort these numbers 1 2 3 4 5 6 7 8 4.5 Since we have an even number of elements median will be an average of 4 and 5 7 2 3 1 4 56 4 The same number 4 would appear in the median 4 7 20 1 13 11 18 12 11.5 Average of 11 and 12 Problem 3 (20 points): Suppose you have a queue containing N unique numbers. Your task is to find the median of these numbers using only available queue operations (enqueue, dequeue, size, and isEmpty). Write down the steps using bullet points for solving this problem such that your pseudocode is easier to understand. Additionally, write a very high-level pseudocode and runtime analysis of your program. Note that your queue contents should be left unchanged after the execution. Your extra space usage should be 0(1), which means that you can only use variables in addition to the input queue (i.e., no extra arrays, queues, or any other data structure). Examples: Input Output Comment 1 2 3 4 5 6 7 4 Median is the middle number that would appear if you sort these numbers 1 2 3 4 5 6 7 8 4.5 Since we have an even number of elements median will be an average of 4 and 5 7 2 3 1 4 56 4 The same number 4 would appear in the median 4 7 20 1 13 11 18 12 11.5 Average of 11 and 12

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!