Question

Assume that your machine has a built-in data structure that inserts an item into a priorityqueue...

Assume that your machine has a built-in data structure that inserts an item into a priorityqueue in one step. There is no charge to remove an item. It has both a min-priority queue anda max-priority queue available. You can access the largest element for one comparison step ina max-priority queue, and similarly you can access the smallest element for one comparisonstep in a min-priority queue.

This machine can sort a list in linear time: Insert all of the elements into a priority queue andthen remove them (one at a time). This isnqueue inserts and no comparisons, for list of sizen.

What if your priority queue is restricted to having sizes? You can assume that your algorithmmay have many different priority queues (but each can have size at mosts). You can distinguishelements in the priority queue (perhaps by their original index in the list).

(a) i. Design an efficient algorithm based on merge sort. You may describe it in high levelEnglish or in pseudo code, but the algorithm must be clear.

ii. Analyze its time: Give the number queue inserts and number of comparisons as pre-cisely as reasonably possible. At least give the high order term exactly. Your answer should be a function of the list size,n, and the queue size,s.

(b) i. Design an efficient algorithm based on heapsort. You may describe it in high levelEnglish or in pseudo code, but the algorithm must be clear.

ii. Analyze its time: Give the number queue inserts and number of comparisons as pre-cisely as reasonably possible. At least give the high order term exactly. Your answer shoul be a function of the list size,n, and the queue size,s.

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using...
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as appropriate [(2)] Let Q be a non-empty queue,...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b,...
Problem Definition: Problem: Given an array of integers find all pairs of integers, a and b, where a – b is equal to a given number. For example, consider the following array and suppose we want to find all pairs of integers a and b where a – b = 3 A = [10, 4, 6, 16, 1, 6, 12, 13] Then your method should return the following pairs: 4, 1 15, 12 13, 10 A poor solution: There are...
Acme Super Store is having a contest to give away shopping sprees to lucky families. If...
Acme Super Store is having a contest to give away shopping sprees to lucky families. If a family wins a shopping spree each person in the family can take any items in the store that he or she can carry out, however each person can only take one of each type of item. For example, one family member can take one television, one watch and one toaster, while another family member can take one television, one camera and one pair...
IntNode class I am providing the IntNode class you are required to use. Place this class...
IntNode class I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is. struct IntNode { int data; IntNode *next;...
Suppose that you want to add items to an array such that the items are always...
Suppose that you want to add items to an array such that the items are always ordered in ascending order; e.g., [1, 2, 2, 4, 5, 8, 9, 14, 32], and any duplicate values are adjacent to each other. We haven’t talked about sorting algorithms yet, so assume you want to be able to keep the items in the array in order without having to sort them. So for example, suppose you want to add the integer value 7 to...
CASE STUDY: DATA WAREHOUSING AT VOLVO Every Volvo car has hundreds of microprocessors and sensors. Their...
CASE STUDY: DATA WAREHOUSING AT VOLVO Every Volvo car has hundreds of microprocessors and sensors. Their data is used in diagnosis and repair. It is also captured by Volvo, integrated with the company's CRM, dealership and product data stores, and stored for analysis. This enables Volvo to spot design and construction flaws early, enable proactive correction of faults, and see how its cars respond in accidents. Volvo sells about 400,000 cars per year. Each generates 100–150 kB of data per...
CASE STUDY: DATA WAREHOUSING AT VOLVO Every Volvo car has hundreds of microprocessors and sensors. Their...
CASE STUDY: DATA WAREHOUSING AT VOLVO Every Volvo car has hundreds of microprocessors and sensors. Their data is used in diagnosis and repair. It is also captured by Volvo, integrated with the company's CRM, dealership and product data stores, and stored for analysis. This enables Volvo to spot design and construction flaws early, enable proactive correction of faults, and see how its cars respond in accidents. Volvo sells about 400,000 cars per year. Each generates 100–150 kB of data per...
CASE STUDY: DATA WAREHOUSING AT VOLVO Every Volvo car has hundreds of microprocessors and sensors. Their...
CASE STUDY: DATA WAREHOUSING AT VOLVO Every Volvo car has hundreds of microprocessors and sensors. Their data is used in diagnosis and repair. It is also captured by Volvo, integrated with the company's CRM, dealership and product data stores, and stored for analysis. This enables Volvo to spot design and construction flaws early, enable proactive correction of faults, and see how its cars respond in accidents. Volvo sells about 400,000 cars per year. Each generates 100–150 kB of data per...
History of Present illness: Mrs.Tomy, patient of Dr. Brents, has been admitted for removal of her...
History of Present illness: Mrs.Tomy, patient of Dr. Brents, has been admitted for removal of her gallbladder. She presented to the hospital with severe 10/10 epigastric pain that caused nausea and vomiting. She is now one day post-op cholecystectomy that was done laparoscopically.. The patient attributes poor control of her diabetes over the past 6 months to the increased stress of caring for her husband with little support. Social History: Lives with husband Henry, who has advancing dementia. They have...
What are your top 3 take aways from this article? Technology is no longer just for...
What are your top 3 take aways from this article? Technology is no longer just for geeks. The internet has changed everything, including marketing. Be they small, medium or large, social media grants all companies an equal playing field on which to organically reach new customers. However, success will always ride on the marketing strategy employed. Obviously, larger companies have the advantage of bigger budgets and more resources. But that doesn’t mean social media for small business owners can’t compete...