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
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:
dintas "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
We have a generic heap implemented as an array, that has been initialized with the following compare
function:
if intx inty: retum
else if intx inty: return
else:
if x
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
