Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions