Question: C++ Programming: Program Design Including Data Structures Ch 16 7th Edition 1. Suppose that first is a pointer to a linked list. What is stored
C++ Programming: Program Design Including Data Structures Ch 16 7th Edition
1. Suppose that first is a pointer to a linked list. What is stored in first?
2. Consider the linked list shown in the figure below. Assume that the nodes are in the usual info-link form. Use this list to answer Exercises 6 through 14. If necessary, declare additional variables. (Assume that list, current, temp, trail, and last are pointers of type nodeType.)

What are the effects, if any, of each of the following C++ statements?
a. trail->link = NULL; delete last;
b. temp->link =trail;
c. list->info = 19;
d. current = current->link; current->link = temp->link;
3. Using the figure from question 2 what is the output of the following C++ code?
a. while (current != NULL) cout info link; cout
b. while (current != last) current = current->link; cout info
4. Using the figure from question 2:
a. If the following C++ code is valid, show the output. If it is invalid, explain why.
ccurrent = temp->link; trail = list; temp = list->link; trail = temp; temp->link = current->link; current = trail->link; cout info info
5. Assume that the node of a linked list is in the usual info-link form with the info of type int. (list and ptr are pointers of type nodeType.) The following code creates a linked list:
ptr = new nodeType; ptr->info = 16; list = new nodeType; list->info = 25; list->link = ptr; ptr = new nodeType; ptr->info = 12; ptr->link = NULL; list->link->link = ptr;
Use the linked list created by this code to answer the following questions. (These questions are independent of each other.) Declare additional poin- ters if you need them.
a. Which pointer points to the first node of the linked list?
b. Determine the order of the nodes of the linked list.
c. Write a C++ code that creates and inserts a node with info 45 after the node with info 16.
d. Write a C++ code that creates and inserts a node with info 58 before the node with info 25. Does this require you to the change the value of the pointer that was pointing to the first node of the linked list?
e. Write a C++ code that deletes the node with info 25. Does this require you to the change the value of the pointer that was pointing to the first node of the linked list?
list 7535 861-10 501 28 551-39 current temp trail last
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
