Question: Using the following UML diagram and class description, write a class named MyList which implements a linked list. Class Attributes: - Node is a nested

Using the following UML diagram and class description, write a class named MyList which implements a linked list.

Using the following UML diagram and class description, write a class named

Class Attributes:

- Node is a nested struct. It's members are:

- value - stores an integer value.

- next - stores the memory address of the next node in the list.

- Head - The head pointer. Stores the memory address of the first node in the list.

- Constructor - initializes head to null.

- Destructor - frees all memory used by the list.

- isFull - returns true if there's NOT enough memory to create a new node, false otherwise.

- isEmpty - returns true if the list is empty, false otherwise.

- find - searches the list for it's argument. Returns true if it's found, false otherwise.

- remove - removes the first node found matching the argument passed to remove. Returns 0 if a node is removed, -1 otherwise.

- append - attempts to append it's argument to the list in a new node. Returns 0 if successful, -1 otherwise.

- clear - frees all memory used by the linked list, leaving head set to null.

- print - displays the contents of the list to the screen.

Notes:

- The class does not interact with the user in any way, so no cin or cout statements. (exception: print())

- All accessors should be marked const. My definition of accessor is any method that doesn't change the head pointer.

- struct Node is nested in class MyList and is private.

- Be sure to include preprocess guards( #ifndef, #define, #endif).

Hints:

- Save yourself from writing duplicate code by having the class destructor call the clear method.

MyList Node next Node* +find(k :int): bool +remove(k :int): int +append(k: int): int

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!