Question: Consider the Linked list discussed in the class (must use the code discussed in class, provided in the textbook any changes made to it must
- Consider the Linked list discussed in the class (must use the code discussed in class, provided in the textbook any changes made to it must be documented and explained).
template
class Node
{
public:
Node();
Node(T value, Node
T data;
Node
};
template
class LinkedList
{
public:
LinkedList();
Node
Node
void ListAppend(T value); // inserts an element at the end of the list.
void listPrepend(T value); //inserts a n element at the head of the list.
void insertAfter(Node
void removeAfter(Node
void removeHead(); // Removes the first element.
void removeTail(); // removes the last element.
void printList() const; // print the elements of the linked list.
private:
Node
Node
};
Add the following functions to the class LinkedList (No need to run your code, unless you want to. The code must be syntactically correct.)
- getLength(): returns the number of items in the LinkedList.
- search(T element) : searches for the element in the LinkedList, returns a pointer to the Node containing the element if found, otherwise returns NULL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
