Implement a Queue in Python¶
Begin by reading about the Queue data structure.
Tasks¶
Create a new branch in your data structures repository called queue
.
On this new branch, create a file called que_.py
.
IT IS IMPORTANT THAT YOU NAME IT THIS WAY, AND NOT queue.py!
If you name it queue.py
, you’re gonna have a bad time.
On that branch, write tests for and then implement a Queue
with the following features:
- enqueue(value): adds value to the queue
- dequeue(): removes the correct item from the queue and returns its value (should raise an error if the queue is empty)
- peek(): returns the next value in the queue without dequeueing it. If the queue is empty, returns None
- size(): return the size of the queue. Should return 0 if the queue is empty.
As with the linked list and stack assignments before this, you may not use any
existing Python implementation to create your queue.
You must also enable this structure to interact with the built-in len()
.
You should update the repository README.md
with information about the Queue you implemented, including any resources or collaborations you used.
Submitting Your Work¶
When your tasks are complete and all tests are passing, submit a pull request
from your queue branch back to master
. Copy the URL for that pull request and
submit it. After you submit your assignment, you may merge your queue branch
back to master
.
Use the comment feature in Canvas to submit questions, comments and reflections.