2.5. Quiz
Quiz 2: Priority Queues
Coding
Create a class called
TernaryHeapQuiz
under the mainqueue
package that extends the abstract classAbstractPriorityQueue
.Each node in
TernaryHeapQuiz
takes up to 3 children, so it becomes a ternary instead of a binary tree.Feel free to use the code in
BinaryHeap
.
Testing
Create the
TernaryHeapQuizTest
class under the testqueue
package.Test the correctness of your
TernaryHeapQuiz
using thetestRobustness()
method.Add more tests for a more thorough assessment if necessary.
Benchmarking
Compare runtime speeds between
BinaryHeap
andTernaryHeapQuiz
foradd()
andremove()
using thetestRuntime()
method.Create a PDF file quiz2.pdf and write a report that includes the following:
A table and a chart to compare speeds between the two priority queues for those two methods,
add()
andremove()
, with respect to different input sizes.A brief explanation of why a certain PQ is faster than the other PQ with respect to different input sizes.
Submission
1. Commit and push everything under the following packages to your GitHub repository:
2. Submit quiz2.pdf to Canvas.
Last updated
Was this helpful?