Giter Site home page Giter Site logo

stacks-queues's Introduction

Stacks & Queues

In this exercise we will implement both a stack & a queue, and then use them in a variety of hands-on exercises.

Learning Goals

By the end of this exercise you should be able to:

  • Implement a stack & a queue using linked lists and arrays
  • Write a Queue using a circular buffer
  • Use a stack and a queue to solve common interview problems.

Wave 1 - Implement a Stack

Using a Linked list (from a previous exercise) implement a Stack with the following methods:

  • push(value) - Adds the value to the top of the stack
  • pop - Removes and returns an element from the top of the stack
  • empty? returns true if the stack is empty and false otherwise

Wave 2 Implement a Queue

Using a circular buffer with an internal array starting at 20 elements, implement a Queue with the following methods:

  • enqueue(value) - Adds the value to the back of the queue.
    • This method should raise a QueueFullException if the buffer size is exceeded (20 elements).
  • dequeue - removes and returns a value from the front of the queue
  • empty? returns true if the queue is empty and false otherwise

Note: You are required to implement this Queue class using a circular buffer. Do not use a linked list.

Going Further

Currently the Queue should report a QueueFullException if more elements are added than can be stored in the queue. To go further make the buffer resize if more elements are needed, but retain the circular buffer methodology. You will need to adjust a test.

Additional Exercise

If you finish the previous waves, complete breadth-first-search on the binary trees project using a Queue.

stacks-queues's People

Contributors

cheezitman avatar sudocrystal avatar gclenda avatar kaidamasaki avatar mmcknett avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.