Question: Need help with these adding these functions to the code below.Please implement these functions to remove nodes from the list, as well as an alternate

Need help with these adding these functions to the code below.Please implement these functions to remove nodes from the list, as well as an alternate way of iterating through your nodes to print them using recursion.
Removal functions:
RemoveHead() Deletes the first Node in the list.Returns whether or not the Node was removed
RemoveTail() Deletes the last Node, returning whether or not the operation was successful
RemoveAt() Deletes the index - th Node from the list, returning whether or not the operation was successful
Remove() Remove ALL Nodes containing values matching that of the passed - in paramter Returns how many instances were removed
Clear() Deletes all Nodes. Dont forget the node counthow many nodes do you have after you deleted all of them
Recursive Print Functions:
PrintForwardRecursive() This function takes in a pointer to a Nodea starting node.From that node,recursively visit each node that follows, in forward order, and print their values. This function MUST be implemented using recursion, or tests using it will be
worth no points.
PrintReverseRecursive() Same deal as PrintForwardRecursive, but in reverse. Must use recursion
#include
#include
#include
using namespace std;
template class T>
class LinkedList
{
public:
class Node {
public:
Node(){
this->next = this->prev = nullptr;
}
T data;
Node* next, * prev;
};
LinkedList(){
head = tail = nullptr;
length =0;
}
~LinkedList(){
if (head == nullptr){
return;
}
Node* current = head;
Node* prev = nullptr;
while (current != nullptr){
prev = current;
current = current->next;
delete prev;
}
delete current;
}
LinkedList(const LinkedList& otherList){
head = nullptr;
tail = nullptr;
length =0;
Node* current = otherList.Head();
while (current != nullptr){
AddTail(current->data);
current = current->next;
}
}
void AddHead(const T data){
if (head == nullptr)
{
head = new Node;
head->data = data;
tail = head;
} else{
Node* new_node = new Node();
new_node->data = data;
new_node->next = head;
head->prev = new_node;
head = head->prev;
}
length++;
}
void AddTail(const T data){
if (tail == nullptr){
tail = new Node;
tail->data = data;
head = tail;
}else{
Node* new_node = new Node();
new_node->data = data;
new_node->prev = tail;
tail->next = new_node;
tail = tail->next;
}
length++;
}
unsigned int NodeCount() const{
return length;
}
void PrintForward(){
Node* ptr = head;
while (ptr != nullptr){
cout ptr->data endl;
ptr = ptr->next;
}
}
void PrintReverse(){
Node* ptr = tail;
while (ptr != nullptr){
cout ptr->data endl;
ptr = ptr->prev;
}
}
void AddNodesHead(const T arr[], const unsigned int count){
for (int i = count -1; i >=0; i--){
AddHead(arr[i]);
}
}
void AddNodesTail(const T arr[], const unsigned int count){
for (unsigned int i =0; i count; i++){
AddTail(arr[i]);
}
}
Node* Find(const T val){
Node* front = head, * back = tail;
Node* ptr = nullptr;
if (front == nullptr && back == nullptr){
return nullptr;
}
while (front = back){
if (front->data == val){
ptr = front;
break;
} else if (back->data == val){
ptr = back;
break;
}
front = front->next;
back = back->prev;
}
return ptr;
}
const Node* Find(const T val) const{
Node* front = head, * back = tail;
Node* ptr = nullptr;
if (front == nullptr && back == nullptr){
return nullptr;
}
while (front = back){
if (front->data == val){
ptr = front;
break;
}else if (back->data == val){
ptr = back;
break;
}
front = front->next;
back = back->prev;
}
return ptr;
}
void FindAll(vector& nodes, const T search_val){
Node* ptr = head;
while (ptr != nullptr){
if (ptr->data == search_val)
nodes.push_back(ptr);
ptr = ptr->next;
}
}
T& operator[](const unsigned int index){
if (index >= length) throw out_of_range("Out of Range");
Node* ptr = head;
for (unsigned int i =0; i index; i++){
ptr = ptr->next;
}
return ptr->data;
}
Node* Head() const{
return head;
}
Node* Tail() const{
return tail;
}
Node* GetNode(const unsigned int index){
if (index >= length){
throw out_of_range("Out of Range");
}
Node* ptr = head;
for (unsigned int i =0; i index && ptr != nullptr; i++){
ptr = ptr->next;
}
return ptr;
}
LinkedList& operator=(const LinkedList& otherList){
Node* temp = head;
Node* prev = nullptr;
while (temp != nullptr){
prev = temp;
temp = temp->next;
delete prev;
}
head = nullptr;
tail = nullptr;
length =0;
Node* current = otherList.Head();
while (current != nullptr){
AddTalength =0;
Node* current = otherList.Head();
while (current I= nullptr){
AddTail (current data);
current = current
 Need help with these adding these functions to the code below.Please

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!