Question: Java Question 7 (TCO 2) Which linked list operation does the operation method below define? public void operation(int item) { Node old = first.getNext(), p

Java

Question 7

(TCO 2) Which linked list operation does the operation method below define? public void operation(int item) { Node old = first.getNext(), p = first; boolean found = false; while (old != null && !found) { if (old.getInfo() == item) found = true; else { p = old; old = p.getNext(); } } if (found) p.setNext(old.getNext()); }

It displays the list elements.
It finds if item is contained in the linked list.
It inserts item in the linked list.
It removes item from the linked list.

Question 8

(TCO 2) The following declaration corresponds to the node type of a _____ data structure. public class Node { private int data; private Node next; private Node previous; //Class methods }

linked list
doubly linked list
circular linked list
linked list with a header node

Question 9

(TCO 2) Suppose that the method below is one of the methods in a LinkedList class. Assume that the list has a dummy header node and that the list is not empty. The method returns which of the following? public int operation() { Node current = first.getNext(); int value = current.getInfo(); while (current != null) { if(current.getInfo() < value) value = current.getInfo(); current = current.getNext(); } return value; }

The sum of all list elements
The smallest element in the list
The greatest element in the list
The number of elements in the list

Question 10

(TCO 2) Suppose that first is the dummy header node of a linked list. The code below _____. Node current = first; while (current.getNext() != null) { current = current.getNext(); } System.out.println(current.getInfo());

prints the information stored in the first node
prints the information stored in the second node
prints the information stored in the node before the last
prints the information stored in the last node

Question 11

(TCO 2) Which of the following produces an execution error if the value of current is null?

Node current = new Node();
if (current != null) System.out.println(Not null);
System.out.println(current.getInfo());
current = null;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!