What is the value of each of the following relational expressions? (3, 4) a. cur
ID: 3830920 • Letter: W
Question
What is the value of each of the following relational expressions? (3, 4)
a. current->link ¼¼ temp
b. temp->link->link->info ¼¼ 50
c. trail->link->link ¼¼ 0
d. last->link ¼¼ nullptr
e. list ¼¼ current
8. What are the effects, if any, of each of the following C++ statements? (3, 4)
a. trail->link ¼ nullptr;
delete last;
b. temp->link ¼ trail;
c. list->info ¼ 19;
d. current ¼ current->link;
current->link ¼ temp->link;
9. Write C++ statements to do the following: (3, 4)
a. Set the info of the second node to 52.
b. Make current point to the node with info 10.
c. Make trail point to the node before temp.
d. Make temp point to an empty list.
e. Set the value of the node before trail to 36.
f. Write a while loop to make current point to the node with info 10.
10. Mark each of the following statements as valid or invalid. If a statement is
invalid, explain why. (3, 4)
a. current ¼ list;
b. temp->link->link ¼ nullptr;
c. trail->link ¼ 0;
d. *temp ¼ last;
e. list ¼ 75;
f. temp->link->info ¼ 75;
g. current->info ¼ trail->link;
h. *list ¼ *last;
i. current ¼ last;
j. cout << trail->link->link->info;
What is the output of the following C++ code? (3, 4)
a. while (current != nullptr)
cout << current->info << " ";
current = current->link;
cout << endl;
b. while (current != last)
current = current->link;
cout << current->info << " ";
cout << endl;
If the following C++ code is valid, show the output. If it is invalid, explain
why. (3, 4)
current = temp->link;
trail = list;
temp = list->link;
trail = temp;
temp->link = current->link;
current = trail->link;
cout << trail->info << " " << current->info << endl;
Explanation / Answer
What is the value of each of the following relational expressions? (3, 4)
a. current->link ¼¼ temp //I believe thats a == operator. So, current->link is pointing to a node with value 35, and temp is pointing to a node with value 86, and therefore, both are not equal. So, the answer is FALSE.
b. temp->link->link->info ¼¼ 50 //temp is pointing to a node with value 86, temp->link is pointing to a node with value 10, and temp->link->link is pointing to a node with value 50. So, the answer is TRUE.
c. trail->link->link ¼¼ 0 //trail is pointing to 65, and trail->link is pointing to 39 valued node, and trail->link->link is pointing to NULL, so the value is 0. TRUE.
d. last->link ¼¼ nullptr //last->link is grounded, and is therefore equal to nullptr. So, the answer is TRUE.
e. list ¼¼ current //list and current both are pointing to the same node, and are equal. So, the answer is TRUE.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.