Question: I need help with the following questions. We are using the book Data Structures and Other Objects Using C++ 4th edition by Michael Main and
I need help with the following questions. We are using the book "Data Structures and Other Objects Using C++" 4th edition by Michael Main and Walter Savitch. I believe i have most of it figured out but the most i stair at it the more i want to go back and change something


1. (30 points) Given the following link that has 3 nodes (Figure 1), where each two components: an integer variable "data field" and a pointer link-field', pointing to the next node in the list. We also have a pointer head_ptr" pointing to the head of the list and a pointer "previous_ptr" pointing to the second node head_ptr 2 3 NULL previous_ptr Figure 1 a. (8 points) Write a function void list_head insert(node*& head_ptr, const int &entry); where a new code containing the given entry is added at the head of the list. You can write either C++ code or pseudo code b. (8 points) Write a function void list_insert(node* previous_ptr, const int &entry) where a new code containing the given entry is added after the node that previous_ptr points to. You can write either C++ code or pseudo code c. (4 points) After a and b, what output is produced by the following? (data() and next() are two constant member functions in class node data() returns the value of data_field and next() returns the value of link field) couthead-ptr->data( )endl; coutnext()->data)data( )endl
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
