Description
Objectives
• Create, add and delete, and work with a stack using a linked-list
• Create, add and delete, and work with a stack using an array
• Create, add and delete, and work with a queue using a linked-list
• Create, add and delete, and work with a queue using an array
Background
Stacks and Queues are both data structures that can be implemented using either an
array or a linked list. Therefore, to fully understand how they work you will
complete the implementation for both a Stack and a Queue using both an array and a
linked-list.
Assignment
You will be working with a todo list of items that will either go on to a stack or in a
queue. A todo item for all implementations will include the following struct:
struct TodoItem
{
std::string todo;
};
You will also be working with classes in this assignment. The code for header files
for all four implementations are provided in this write-up.
Program Specifications
• Use the starter code in this write-up to create the following header files. Do
not modify what is provided. You will write the implementation files and
submit those only.
Provided Starter Code (do not submit):
o HW4-Todo-StackArray.hpp
o HW4-Todo-StackLinkedList.hpp
o HW4-Todo-QueueArray.hpp
o HW4-Todo-QueueLinkedList.hpp
Files You Create (do submit):
o HW4-Todo-StackArray.cpp
o HW4-Todo-StackLinkedList.cpp
o HW4-Todo-QueueArray.cpp
o HW4-Todo-QueueLinkedList.cpp
• Do NOT add a main method to any of your submitted files.
• DO write your own test drivers to test your code, but do not submit them.
• Your code needs to be readable, efficient, and accomplish the task provided.
• Make sure you delete your dynamically allocated memory in the appropriate
methods!
• When working with array-based implementations, there is a max size
available (set to 5 for this assignment in the header files). Display an error
message if attempting to add to a full array:
“Stack full, cannot add new todo item.”
Or “Queue full, cannot add new todo item.”
Note – this does not apply to linked-list implementations.
• If the stack or queue is empty when you try to pop or peek it, display an error
message:
“Stack empty, cannot pop an item.”
“Stack empty, cannot peek.”
“Queue empty, cannot dequeue an item.”
“Queue empty, cannot peek.”
• Make sure your code is commented enough to describe what it is doing.
Include a comment block at the top of all .cpp files with your name,
assignment number, and course instructor, and anyone you worked with.
• You must implement the functions as specified. You do not need any
additional functions. Each .hpp file has one or more getter methods that are
defined in the header. You do not need to implement these.
• Use the following code for your header files, and name them as indicated. DO
NOT MODIFY.
HW4-Todo-QueueArray.hpp
#ifndef HW4_TODO_QUEUEARRAY
#define HW4_TODO_QUEUEARRAY
#include