Example Code Ch 13-3
Assume that countIt and sumIt methods receive a parameter, Node temp, which references the first Node in a linked list where Node is a class that consists of data instances int info and Node next, and further assume that the int variables count and sum are initialized to 0.
-Refer to Example Code Ch 13-3: Which of the following methods could be used to count the number of items in the linked list?
A) public int countIt(Node temp)
{
While (temp != null)
{
Count += temp.info;
Temp = temp.next;
}
Return count;
}
B) public int countIt(Node temp)
{
While (temp != null)
{
Count++;
}
Return count;
}
C) public int countIt(Node temp)
{
While (count != null)
{
Count++;
Temp = temp.next;
}
Return count;
}
D) public int countIt(Node temp)
{
While (temp != head)
{
Count++;
Temp = temp.next;
}
Return count;
}
E) public int countIt(Node temp)
{
While (temp != null)
{
If (next != null) count++;
Temp = temp.next;
}
Return count;
}
Correct Answer:
Verified
Q27: Example Code Ch 13-2
Assume that a linked
Q28: Example Code Ch 13-2
Assume that a linked
Q29: Example Code Ch 13-4
Assume that a linked
Q30: Example Code Ch 13-4
Assume that a linked
Q31: In a linked list in Java
A) the
Q33: Example Code Ch 13-2
Assume that a linked
Q34: Example Code Ch 13-2
Assume that a linked
Q35: To simulate people waiting in a line,
Q36: Example Code Ch 13-3
Assume that countIt and
Q37: Example Code Ch 13-4
Assume that a linked
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents