arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

2.5. Quiz

Quiz 2: Priority Queues

hashtag
Coding

  • Create a class called TernaryHeapQuizarrow-up-right under the main queuearrow-up-right package that extends the abstract class AbstractPriorityQueuearrow-up-right.

  • Each node in TernaryHeapQuiz takes up to 3 children, so it becomes a ternary instead of a binary tree.

  • Override the required abstract methods, , , and , such that both add() and remove() give .

  • Feel free to use the code in .

hashtag
Testing

  • Create the class under the test package.

  • Test the correctness of your TernaryHeapQuiz using the method.

  • Add more tests for a more thorough assessment if necessary.

hashtag
Benchmarking

  • Compare runtime speeds between BinaryHeap and TernaryHeapQuiz for add() and remove() using the method.

  • Create a PDF file quiz2.pdf and write a report that includes the following:

hashtag
Submission

1. Commit and push everything under the following packages to your GitHub repository:

  • Main:

  • Test:

2. Submit quiz2.pdf to Canvas.

A table and a chart to compare speeds between the two priority queues for those two methods, add() and remove(), 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.

  • O(log3n)O(log_3 n)O(log3​n)
    add()arrow-up-right
    remove()arrow-up-right
    size()arrow-up-right
    BinaryHeaparrow-up-right
    TernaryHeapQuizTestarrow-up-right
    queuearrow-up-right
    testRobustness()arrow-up-right
    testRuntime()arrow-up-right
    src/main/java/edu/emory/cs/queuearrow-up-right
    test/java/edu/emory/cs/queuearrow-up-right