Solved

A Linked List Class Uses a Node Class with Successor

Question 27

Multiple Choice

A linked list class uses a Node class with successor reference next,and uses a reference first to point to the first node of the list.A positive index k is given,and we want to set a reference pred to point to the node with index k-1.The right code to use is


A) pred = first;
For (int i = 0;i < k;i++)
Pred = pred.next;
B) pred = first;
For (int i = 0;i < = k;i++.
Pred ++;
C) pred = first;
For (int i = 1;i < k;i++.
Pred = pred.next;
D) pred = head;
For (int k : list.
K--;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions