Skip to content

Instantly share code, notes, and snippets.

@thenickcox
Created January 10, 2017 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thenickcox/5f592977fdb2cce4c57f7ce1de24ae8b to your computer and use it in GitHub Desktop.
Save thenickcox/5f592977fdb2cce4c57f7ce1de24ae8b to your computer and use it in GitHub Desktop.

Explain and Implement a Queue

A queue is a common data structure that is often used in computer science.

  1. In your own words (300-500 words will suffice), explain–in your own words–what a queue is, what its uses are, common properties of queues.
  2. Implement a queue in your language of choice. It should have the following methods:
  3. enqueue: place an item into the queue, return the queue
  4. dequeue: take the appropriate item off of the queue, return the queue
  5. peek: return the first item from the queue, but do not remove it
  6. size: the number of items in the queue
  7. Discuss any potential trade-offs of your approach, including performance, memory allocation, or related concerns. Discuss any related methods that would be useful.

Approach this problem as though you were designing this as a third-party library that would be included in other programs.

The final format should be a README.md file containing the answers to questions 1 and 3, as well any related files and/or directories necessary for implementation.

Please note that if you choose a language that already contains a queue or a queue-like data structure, there is a strong preference that you would implement a queue from scratch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment