Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago

Question

What is gravity?

Answered: 1 week ago

Question

What is the Big Bang Theory?

Answered: 1 week ago

Question

2 What people-related issues do you foresee?

Answered: 1 week ago