The next set of questions list code and ask you to describe the contents of the
ID: 3727080 • Letter: T
Question
The next set of questions list code and ask you to describe the contents of the chain headed by firstNode and the value of the node referred to be currentNode. Please also explain why.
Node a = new Node(5);
Node b = new Node(3, a);
Node c = new Node(7, b);
Node firstNode = new Node(2, c);
Node current = firstNode;
current.next.next.data = 8;
Question 1: What is the contents of the chain headed by firstNode?
F. 2->7->8->5
Question 2: What is the data held in the node referred to by current?
Node a = new Node(5);
Node b = new Node(3, a);
Node c = new Node(7, b);
Node firstNode = new Node(2, c);
Node currentNode = firstNode;
currentNode.data = 15;
Question 3: What is the contents of the chain headed by firstNode?
F. 15
Question 4: What is the data held in the node referred to by currentNode?
F. 15
A. 2->7Explanation / Answer
Q.1
The chain pointed by first node is as follows:
2->7->8->5
Every time a node is created. It gets created with a value and its next pointing to the
second argument.
new Node(5); means a node with value 5 and its next pointing to NULL
new Node(3,a) means a node with value 5 and its next pointing to a
and so on.
current modifies the content on third node with 8
Q2.
The data held in node refered by current is 2
Q3.
As explained above the chain pointed by firstNode is
15->7->3->5
Q4.
The data held in the node refered by current is 15
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.