Question
(1) Create a set of Linked Lists using pointers, and associated member functions, then test each function in your main function. Use LinkedList.hPreview the document
(1) Create a set of Linked Lists using pointers, and associated member functions, then test each function in your main function. Use LinkedList.hPreview the document as your base. You can add member functions as necessary. Implement each of these functions to provide the correct functionality. These functions return true if successful in inserting or deleting, otherwise they return false (indicating the operation was not successful). Because we are dealing with pointers you should have both a LinkedList Constructor and Destructor. Remember that you do not directly call a Constructor or Destructor Function. The Destructor is automatically called when the variable loses scope or the program ends. Remember, that we are dealing with not just one dynamically allocated Node (with the new operator), but many, so you will have to start at the head of the list and go until the Node points to nullptr. Then keep deleting the previous Node pointer until there are no Nodes left to delete.
(2) To verify your LinkedList class, write a main function that tests each function and prints the results.
(3) Please also complete an asymptotic (Big O) analysis of your insertAtFront() and insertAtBack() member functions. Place this in a file called analysis.txt.
THE LINKEDLIST.h file is as follow
#include
using namespace std;
struct Node
{
char data = 0;
Node* nextPtr = nullptr;
};
class LinkedList
{
private:
Node *headPtr;
public:
LinkedList();
~LinkedList();
bool insertAtFront(char value);
bool insertBeforePosition(char value, int index);
//first Node after headptr is 1
//false if pos zero or out of range
bool insertAtBack(char value);
bool deleteAtFront();
bool deletePosition(int index);
//first Node after headptr is 1
//false if pos zero or out of range
bool deleteAtBack();
//false if empty
void clear(); //frees memory for entire list
friend ostream& operator << (ostream &out, LinkedList &list);
};
USE C++ language only
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