42.2k views
1 vote
Suppose head is a head reference for a linked list. Also suppose douglass and adams are two other IntNode variables. Write one assignment statement that will make douglass refer to the first node in the list that contains the number 42. Write a second assignment statement that will make adams refer to the 42nd node of the list. If these nodes don't exist, then the assignments should set the variables to null.

User Covi
by
8.0k points

1 Answer

6 votes

Final answer:

To make douglass refer to the first node in the list that contains the number 42, use the assignment statement 'douglass = head'. To make adams refer to the 42nd node of the list, use the assignment statement 'adams = head'. If the nodes don't exist, the variables will be set to null.

Step-by-step explanation:

To make douglass refer to the first node in the linked list that contains the number 42, you can use the following assignment statement:

douglass = head;

To make adams refer to the 42nd node of the list, you can use the following assignment statement:

adams = head;

If either of these nodes don't exist, the assignments will set the variables to null.

User Shubham Chopra
by
7.9k points