I Haz Codes

Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Creating an OO queue

Note – Do the stack tasks first!

basing the code on the stack you have already coded, try and create a queue class. You will need to make use of the Node class.

The queue class will have the following attributes –

Front – Points to the front of the queue

rear – points to the end of the queue.

It will have the following methods –

add(value) – Adds an item to the rear of the queue.

  • Create a new node.
  • If the queue is empty, set both rear and front to point to the new node.
  • Otherwise
    • set the current rear’s previous to be the new node.
    • Set the rear to be the new node.


  • If the front is none (i.e. the queue is empty), display an error.
  • Store the front into a temp variable.
  • set the front to be the previous of that temporary node.
  • return the temporary node

You need to log in or create an account to submit code!

Comments are closed.