Queues and Priority Queues
Objectives
- To gain familiarity with object oriented
programming (OOP) in php
- To continue to gain familiarity with arrays
- To continue to gain familiarity with php
Part I: Queue Implementation
Implement a queue in a file named queue.php
such that when this file (renamed lab.php) is
run, it produces this output
exactly. Remember to view the source in order
to see the exact details.
Part II: Priority Queue Implementation
Implement a priority queue in a file named priorityQueue.php
such that when this file
(renamed lab.php and suitably modified to use a priority queue
instead of a queue) is run,
it produces this output
exactly.
Helpful Hints
- Use an array as the underlying data structure. Arrays in
php are ordered maps that can consequently be used to implement
lists, hash tables, stacks, queues and many other abstract
data types (ADTs).
- Do Part I first as you should be able to reuse much of
this solution for Part II.
Requirements
- This file (renamed item.php) is used
without modification in your solution.
- The queue.php contains a protected
method named isEmpty that is used by the
dequeue method.
- The queue.php file uses access modifiers
correctly.
- The queue.php file generates the correct
answer.
- The priorityQueue.php file contains as few
functions as possible.
- The priorityQueue.php file generates the
correct answer.