Question: For this lab, you will be implementing both a * Last In/First Out * and * First In/First Out * data structures. These data structures
For this lab, you will be implementing both a *Last In/First Out* and *First In/First Out* data structures. These data structures store data in a way that allows you to only see one value from the structure. You can't see any other value in the structure unless it is the top value. These structures are important because they allow us to add or remove data members to the structure in an O(1) complexity. ### Lab Instructions Implement each of the functions to perform the necessary actions outlined in the `.h` files. As you are writing your functions, read the instructions and think of how you would test that functions while you are writing it. Write your Test first and then implement your functions. Try running your test and then fixing your issues. `lifo_storage` and `fifo_storage` will both be statically sized, meaning that you don't need to worry about dynamically growing the stringVector. Treat it just like an array. #### Fifo #### **fifo()**: Default constructor. Set index properly and reserve 100 spaces in fifo_storage **explicit fifo(std::string input_string)**: Constructor that does the same thing as the default constructor, but adds a single item to the Fifo **fifo(const fifo &original)**: Copy constructor **virtual ~fifo()**: Destructor **fifo &operator=(const fifo &right)**: Assignment operator **bool is_empty() const**: Return true if the fifo is empty and false if it is not **unsigned size() const**: Return the size of the fifo **std::string top() const**: Return the front string of the fifo. **void enqueue(std::string input)**: Add input string to the back of the fifo **void dequeue()**: Remove the front string from the fifo #### Lifo #### **lifo()**: Default constructor. Set index properly and reserve 100 spaces in fifo_storage **explicit lifo(std::string input_string)**: Constructor that does the same thing as the default constructor, but adds a single item to the Fifo **lifo(const lifo &original)**: Copy constructor **virtual ~lifo()**: Destructor **lifo &operator=(const lifo &right)**: Assignment operator **bool is_empty() const**: Return true if the lifo is empty and false if it is not **unsigned size() const**: Return the size of the lifo **std::string top() const**: Return the top of the lifo. **void push(std::string input)**: Add input string to the top of the string **void pop()**: Remove the top string from the lifo.
fifo.cpp
#include "fifo.h" namespace lab3{ fifo::fifo() { //Reserve 100 spaces in fifo_storage } fifo::fifo(std::string input_string) { } fifo::fifo(const fifo &original) { } fifo::~fifo() { } fifo &fifo::operator=(const fifo &right) { //return <#initializer#>; } bool fifo::is_empty() const { //return false; } unsigned fifo::size() const { //return 0; } std::string fifo::top() const { //return std::__cxx11::string(); } void fifo::enqueue(std::string input) { } void fifo::dequeue() { } } lifo.cpp
#include "lifo.h" namespace lab3{ lifo::lifo() { //Reserve 100 spaces in lifo_storage } lifo::lifo(std::string input_string) { } lifo::lifo(const lifo &original) { } lifo::~lifo() { } lifo &lifo::operator=(const lifo &right) { //return <#initializer#>; } bool lifo::is_empty() const { //return false; } unsigned lifo::size() const { //return 0; } std::string lifo::top() const { //return std::__cxx11::string(); } void lifo::push(std::string input) { } void lifo::pop() { } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
