Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Computer Science

Make-a-Queue

Instructions

Make a queue!

A queue is a data strucutre that can be described by the term FIFO (First In First Out). The first element added to the array is the first one you can retrieve from it.

A queue acts a lot like an array, but with a more focused scope.

However, some algorithms are best solved only with the methods available to a queue.

In this exercise, we will make a queue from scratch. Your queue should fall under the following parameters:

  • Your Queue should be a constructor.

  • Initialize your queue with a data argument. Set its default to an empty array (You can do this directly as an argument... for example: function(data = []). If the function is passed an argument, it will take the argument's form otherwise, it will be set to what you defaulted it as in the argument)

  • Your queue should have a data property which points to the argument passed to the queue.

  • It should have an add method that adds an element to the back of the queue

  • It should have a remove method that removes and returns the first element in the queue

  • It should have a peek method that shows the first element in the queue