Question: Problem 1 Working code for Generic Priority Queue Sort can be found in the PYTHON CODE section of our HuskyCT website, where we have a

Problem 1
Working code for Generic Priority Queue Sort can be found in the PYTHON CODE section of our
HuskyCT website, where we have a simple Generic PQ implementation. This code sorts arrays of
numbers, using a compare function compl to initialize the PQ.
Your job is implement three compare functions to sorts arrays of strings, for example:
["dint","as", "cse", "useful", "dinner", "apple", "apt", "is", "hello", "island"]
Try to make your compare functions as simple and elegant as possible. Submit the code for your
compare functions.
a) compA: Sort the strings in regular alphabetic order (so "apple" "apt" and "dinner" "dint")
b) compB: Sort the strings so shorter ones are always in front (so "apt" "apple" > and "dint" "dinner")
c) compC: Same as (b), but "i" is a special letter that goes in front of all others (so "island" "apt")
Hint: Please use the provided code to test your compare functions, but other code should not be
changed, except for the name of the function when you initialize the priority queue.
Problem 2
We have a generic heap implemented as an array, that has been initialized with the following compare
function:
if (int(x/5) int(y/5)): retum -1
else if (int(x/5)> int(y/5)): return 1
else:
if (x17,3,7,2,9,11,13,5,10,16,1,6,4,8,12,14,15
Problem 1 Working code for Generic Priority Queue

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 Programming Questions!