DataStructures-and-Algorithms

Implementation: Stacks and Queues

Specifications

Challenge Setup & Execution

Branch Name: stack-and-queue

Challenge Type: New Implementation

Features

Using a Linked List as the underlying data storage mechanism, implement both a Stack and a Queue

Node

Stack

Queue

You have access to the Node class and all the properties on the Linked List class.

Structure and Testing

Utilize the Single-responsibility principle: any methods you write should be clean, reusable, abstract component parts to the whole challenge. You will be given feedback and marked down if you attempt to define a large, complex algorithm in one function definition.

Be sure to follow your language/frameworks standard naming conventions (e.g. C# uses PascalCasing for all method and class names).

Any exceptions or errors that come from your code should be contextual, descriptive, capture-able errors. For example, rather than a default error thrown by your language, your code should raise/throw a custom error that describes what went wrong in calling the methods you wrote for this lab.

Write tests to prove the following functionality:

  1. Can successfully push onto a stack
  2. Can successfully push multiple values onto a stack
  3. Can successfully pop off the stack
  4. Can successfully empty a stack after multiple pops
  5. Can successfully peek the next item on the stack
  6. Can successfully instantiate an empty stack
  7. Calling pop or peek on empty stack raises exception
  8. Can successfully enqueue into a queue
  9. Can successfully enqueue multiple values into a queue
  10. Can successfully dequeue out of a queue the expected value
  11. Can successfully peek into a queue, seeing the expected value
  12. Can successfully empty a queue after multiple dequeues
  13. Can successfully instantiate an empty queue
  14. Calling dequeue or peek on empty queue raises exception

Ensure your tests are passing before you submit your solution.

Documentation: Your README.md

# Stacks and Queues
<!-- Short summary or background information -->

## Challenge
<!-- Description of the challenge -->

## Approach & Efficiency
<!-- What approach did you take? Why? What is the Big O space/time for this approach? -->

## API
<!-- Description of each method publicly available to your Stack and Queue-->

Submission Instructions

  1. Create a pull request from your branch to your main branch
  2. In your open pull request, leave as a comment a checklist of the specifications and tasks above, with the actual steps that you completed checked off
  3. Submitting your completed work:
    1. Copy the link to your open pull request and paste it into the corresponding assignment
    2. Leave a description of how long this assignment took you in the comments box
    3. Add any additional comments you like about your process or any difficulties you may have had with the assignment
  4. Merge your branch into main, and delete your branch (don’t worry, the PR link will still work)