Question
PLEASE DO NOT SPAM THE QUESTION I WILL AUTOMATICALLY DISLIKE IT (IF YOU SOLVE IT PLEASE POST A PICTURE OF IT WORKING ON YOUR END,
PLEASE DO NOT SPAM THE QUESTION I WILL AUTOMATICALLY DISLIKE IT (IF YOU SOLVE IT PLEASE POST A PICTURE OF IT WORKING ON YOUR END, THANKS)
In C++ I have created a List.h file for a List ADT. Fill in and fix the methods in List.cpp, so we can traverse, insert, remove, read, and modify. Please read the comments that are included in List.cpp.
// File : List.cpp // Desc : Linked List ADT implementation // -------------------------------------------------------- #include "List.h" /** * Default constructor - initialize empty list */ List::List() { } // default constructor /** * Destructor - clean up nodes */ List::~List() { } // destructor /** * Accessor for the list size property * @return int size (empty = 0) */ int List::getSize() { } // getSize /** * Signifies if the list is empty or not * @return bool True if empty (size==0) */ bool List::isEmpty() { } // isEmpty /** * Add a new value into the list at the head, a * specified position, or at the tail if position * is -1 or invalid position * @param value - int value to store * @param position - position in list to store value */ void List::insert(int value, int position) { } // insert /** * Remove a value from the list at a specified position and * return it to the caller * @param position - position in the list or tail if -1 * or invalid position
* @return - value removed from the list */ int List::remove(int position) { } // remove /** * Return a value from the list at a specified position without * removing it * @param position - position in the list * @return - value found at position (-1 if not found or invalid position) */ int List::read(int position) { } // read /** * Modify a value at a specified position in the list * @param value - new value * @param position - position in the list */ void List::modify(int value, int position) { } // modify
---------------------------------------------------------
// File: List.h // Desc: Linked List ADT interface // -------------------------------------------------------- #ifndef LINKEDLIST_LIST_H #define LINKEDLIST_LIST_H const int LIST_HEAD = 0; const int LIST_TAIL = -1; class List { private: struct Node { int value; Node* next; }; Node* head; int size; public: List(); ~List(); int getSize(); bool isEmpty(); void insert(int value, int position=LIST_TAIL); int remove(int position=LIST_TAIL); int read(int position); void modify(int value, int position); }; #endif //LINKEDLIST_LIST_H
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started