We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Queue Class

Assignment

LockedIn uses a Queue to keep track of the order that recruiters should use to reach out to job seekers.

Implement the following operations on the Queue class:

  • queue.push(item): Adds an item to the tail of the queue (index 0 of list)
  • queue.pop(): Removes and returns an item from the head of the queue (last index of list). Returns None if the queue is empty.
  • queue.peek(): Returns an item from the head of the queue. Returns None if the queue is empty.
  • queue.size(): Returns the number of items in the queue

Note: You'll often hear words used interchangeably in programming. For example, here we're saying push and pop, but enqueue and dequeue are also common words for the same ideas.

term 1 term 2 description
Push Enqueue Adds an item to the tail of the queue
Pop Dequeue Removes and returns an item from the head of the queue

Tips

  • A guard clause can check for an empty list before you try to access an item.
  • The .insert List method may be helpful.