> For the complete documentation index, see [llms.txt](https://howtocode.trek.io/topics/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://howtocode.trek.io/topics/deep-dives/computer-science/data-structures/project-stacks-and-queues.md).

# Project: Stacks and Queues

## Introduction

This exercise will be a small one to give you an appreciation of how `queues` and `stacks` work. Of course, a great way to figure out how anything works is to make the thing yourself, so this is what we will be doing in this lesson. This is mostly an academic exercise, so you will be asked to refrain from using `queue-like` or `stack-like` methods in your solution, however tempting this otherwise sensible choice would be.

## Assignment

In your language of choice...

1. Create a "Stack" class, which will have a private array member variable, and two public methods '#push(item)' and '#pop'. Push should add item to the end of your array, and pop should remove from the end.
   * If you're using Ruby, Javascript or similar languages, please try and do this without using the array's push and pop methods for this exercise!
2. Create a "Queue" class, which will have a private array member variable, and two public methods '#enqueue(item)' and '#dequeue'. Enqueue should add item to one end of the array, and Dequeue should remove from the other end.
   * Like with "Stack", please refrain from using 'push' and 'shift' if you're using a language that has these (or similar) methods!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://howtocode.trek.io/topics/deep-dives/computer-science/data-structures/project-stacks-and-queues.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
