Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

So I have created a List.h file and I need to fill in and fix each method on List.cpp in order to traverse, insert, and

So I have created a "List.h" file and I need to fill in and fix each method on "List.cpp" in order to traverse, insert, and read it.

(List.h file)

#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

======================================================================================================

#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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions