Project 3: Stacks and Queues

Start: Tuesday, 9/17; Due: Monday, 9/30, by the beginning of class


Overview

This assignment will give you some practice on implementing and using stacks and queues. You should work on this project individually.

Part 1: Using Stacks

During lectures, I went through the implementation of stacks and queues. For this part of the project, you will learn about a variation of the stack (called undo stack). And, you'll learn how to use stacks in an application.

For this part of the project, you will complete the lab section of Chapter 3 in your textbook (Secton 3.9: Grocery List Editor with Undo Stack). You will complete the missing codes in RemoveLastCommand.py, SwapCommand.py, InsertAtCommand.py, and GroceryList.py. Please follow the steps in the project description carefully, they should provide instructions on what you need to do for each class.

Please feel free to implement any helper functions to assist you. If your functions are too long, and you can isolate any part of a function based on task, you should be constructing a helper function.

Please read and follow the instruction for the lab (in Section 3.9) carefully. You should be able to run your code as you're coding. Once you have finished coding, you can submit your code via the textbook webpage. You do not need to submit to Moodle for this task.

Part 2: Implementing a Deque

A deque is a data structure that combines a stack and a queue. Deque libraries are implemented in many languages, including Ada, C++, Java, Perl, PHP, Python, Ruby, and JavaScript. Each language has a distinct terminology for the defining deque operations, though. We will use Python/Java names for these operations. They are: For this part of the project, we'll take the code for the Queue.py class we worked on during lectures (an array implementation of queue) and turn it into a deque implementation by adding more code to it. You should be able to find Queue.py on Moodle and make modification on top of the existing code.

Based my code for the original Queue.py class. Please write code to implement the above 6 missing deque functions. You should realize that 3 of the 6 functions above are already done for you; you just need to change some minor details such as the function names, and they should work as deque functions.

Finally, write a main.py to do some testing of the six functions you just created in Deque.py. Please note that when doing unit testings, you must test all exception cases as well as normal cases. Please provide all of the exception cases and at lease one normal cases when testing each function. Please document each case with comments. I will give you more details on what I'm expecting during lectures and labs.

Please implement your deque using an array (not a link list).

What you must do/hand in

For part 1 of this project, you wiil complete the code in Section 3.9 of your textbook. Please read the instructions in Section 3.9 carefully and submit your code accordingly.

For part 2 of this project, you must submit Deque.py and main.py via Moodle. Your Deque.py class must contain the six functions listed above and your main.py must contain all the unit testing for the functions.

Grading Guide

We will be using this grading guide when grading your lab.

Submission

Submit part 1 of this project via Section 3.9 of your textbook (be sure to read the follow the submission instruction).

Submit part 2 of this project: Deque.py and Main.py, via Moodle. Be sure to select 2025 f-mcs-178-001, which is your lecture section, then click on the MCS-178 Project 3 Submission link.