Question: 4. Complete the delete_linkedlist method below. It should delete every element in the linked list (e.g., 2, 4, 2, 33, 2). And draw the

4. Complete the delete_linkedlist method below. It should delete every element in the linked list (e.g., 2,

4. Complete the delete_linkedlist method below. It should delete every element in the linked list (e.g., 2, 4, 2, 33, 2). And draw the linked list diagram (when created using insert_to_first) in the main program. using namespace std; class Node { //link-list node public: int data; Node* next; void insert_to_first (Node** head, int data) { } Node* new_node = new Node(); //create node new node->data = data; // add new data new_node->next = (*head); (*head) = new_node; } void delete linkedlist(Node** head) { // delete all elements in the linked list } int main() { Node* head = NULL; insert_to_first (&head, 2); insert_to_first (&head, 4); insert_to_first (&head, 2); insert_to_first (&head, 33); insert_to_first (&head, 2); delete_linkedlist (&head);

Step by Step Solution

3.48 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It seems like theres a typo in your code and there is an extra space in the function names insert to ... View full answer

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 Programming Questions!