if we have following List classes: class Node { T value; Node next; ... } class
ID: 3714585 • Letter: I
Question
if we have following List classes:
class Node
{
T value;
Node next;
...
}
class LinkedList <T> {
private Node head;
... }
use of the following list:
1) Determine the value of the following expressions.
If any of the expressions cannot be evaluated, state why.
(a) temp
(b) temp.value
(c) temp.next.value
(d) head.next
(e) temp.next.next
(f) temp.value.next
(g) head.next.next.value
(h) temp.next.next.next.val
2) Show what the linked list would look like after each of the following statements.
Each statement should be applied to the initial linked list shown above.
If any of these statement are illegal, indicate why.
a) temp.next.value = 15;
f) temp.next = 15;
b) temp.next = temp.next.next;
g) temp.next = null;
c) head = temp;
h) temp.next.value = head.next.value;
d) temp.next = head;
i) temp.next = temp;
e) temp.value = head;
head termpExplanation / Answer
Hi Dear,
I have answered Q1. As per the chegg guideline, please post one question in a post.
1.
a) temp is a reference, so simply temp means hash code of temp (reference value)
b) 7
c) 3
d) reference value of second node (node containg value 5)
e) last node
f) Error
g) 7
h) Null pointer exception
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.