Question: IntNode class I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make

IntNode class

I am providing the IntNode class you are required to use. Place this class definition within the IntList.h file exactly as is. Make sure you place it above the definition of your IntList class. Notice that you will not code an implementation file for the IntNode class. The IntNode constructor has been defined inline (within the class declaration). Do not write any other functions for the IntNode class. Use as is.

struct IntNode { int data; IntNode *next; IntNode( int data ) : data(data), next(0) {} };

IntList class

Encapsulated (Private) Data Fields

head: IntNode *

tail: IntNode *

Public Interface (Public Member Functions)

IntList()

IntList( const IntList &list)

~IntList()

void display() const

void push_front( int value )

void push_back( int value )

void pop_front()

void select_sort()

void insert_sorted( int value )

void remove_duplicates()

int length() const;

int sum() const;

void reverseDisplay() const;

IntList & operator=( const IntList &list )

Constructor and Destructor

IntList() - the default constructor

Initialize an empty list.

IntList(const IntList &list) - the overloaded copy constructor

Initialize a new list with the contents of an existing list.

~IntList()

This function should deallocate all remaining dynamically allocated memory (all remaining IntNodes).

Accessors

void display() const

This function displays to a single line all of the int values stored in the list, each separated by a space. It should NOT output a newline or space at the end.

Mutators

void push_front( int value )

This function inserts a data value (within a new node) at the front end of the list.

void push_back( int value )

This function inserts a data value (within a new node) at the back end of the list.

void pop_front()

This function removes the value (actually removes the node that contains the value) at the front end of the list. Do nothing if the list is already empty. In other words, do not call the exit function in this function as we did with the IntVector's pop_front.

void select_sort( )

This function sorts the list into ascending order using the selection sort algorithm.

void insert_sorted( int value )

This function assumes the values in the list are in sorted (ascending) order and inserts the data into the appropriate position in the list (so that the values will still be in ascending order after insertion). DO NOT call select_sort within this function.

void remove_duplicates()

This function removes all values (actually removes the nodes that contain the value) that are duplicates of a value that already exists in the list. Always remove the later duplicate, not the first instance of the duplicate. DO NOT call select_sort within this function. This function does NOT assume the data is sorted.

int length() const

This function recursively determines the length of the list.

int sum() const

This function recursively determines the sum of all of the elements in the list.

void reverseDisplay() const

This function recursively displays the contents of the list in reverse order.

IntList & operator=(const IntList &list)

This function copies over all of the nodes in an existing list to another already existing list.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!