Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write these 5 functions for for class below: Please write the complete code usin

ID: 3787944 • Letter: W

Question

Write these 5 functions for for class below: Please write the complete code using C++ lanagauge.

1. deconstructor free all memmory on list List: ~List

2. delete oldest node instrted and return it's data value oldest node should be tail_ptr use int List:: pop

3. add a new node to end of the list, and newest node will be heald in head_ptr use void List::push(int new_data)

4. return if the node is containing the passed-in integer is in the list, true if such a node exists, false otherwise use bool List::search(int test_data)

5. remvoves the newest node containaing the passed in integers, only remove ONE node NOT ALL OF THEM. return true if any elements removed, false otherise. Use bool List:: remove(int old_data)

Below is the node.h file and the attahcemnet is the class file. Please help writting the 5 functions please comments on the line.

//This Node class is fully functional
class Node {
int data; //Holds the data we're keeping track of
Node *next;
public:
Node() {
data = 0;
next = NULL;
}
~Node() {
//You: Write a destructor here if you need one
}
Node(int new_data, Node *new_next) {
data = new_data;
next = new_next;
}
int get_data() const { return data; }
Node *get_next() const { return next; }
void set_next(Node *new_next) { next = new_next; }
};

ragma once include Kiostream #include "node.h" using namespace std; class List int list size Node *head ptr //Holds newest member Node *tail ptr //Holds oldest member public: List list size 0; head ptr NULL tail ptr NULL List 0; int get list size const return list size; //Output the list void print list if (head ptr NULL) cout "EMPTY LIST n"; return; Node *temp ptr head ptr int counter 0; while (temp ptr) Same as saying while (temp ptr NULL) cout Node Counter temp ptr->get data endl temp ptr temp ptr->get next //write these functions int pop void push (int new data) bool search (int test data); bool remove int old data)

Explanation / Answer

Find the five required functions below :

1. Destructor

~List() {

cou<< "destructor is called ";

int get_list_size() const {return list_size; }

}

2.
int List::pop() {
List::node *n_tail_ptr;
n_tail_ptr = tail_prt;
tail_ptr = tail_ptr->link();
int a;
int *no = a int[a1];
delete tail_ptr;
return ;
}

3.   
void List::push(int new_data) {
head_ptr = new Node(1, head_ptr);
List *newnode = new List(NULL);
}

4.

bool List::search(int test_data) {
if(list_size) == List::data)

return true;
else
return false;

5.
(int old_data)
bool List::remove (int old_data) {
node *remove_prt;
remove_ptr = head_ptr;
head_ptr = head_ptr->link( );
delete remove_ptr;
return true;
}