What does the following Java code snippet accomplish?
SLLNode snode = new SLLNode(“Cris”);
System.out.println(snode);
(Assuming toString() is not overridden in the SLLNode class.)
A. It throws a runtime error
B. It prints “Cris”
C. It prints the node’s info field
D. It prints the default object reference
D. It prints the default object reference
What value does next hold in the last node of a singly linked list?
A. Zero
B. Previous node
C. Null
D. Head
C. Null
Why is insertion at the head more efficient than insertion at the tail in a singly linked list?
A. It uses less memory
B. It requires no traversal
C. It avoids pointer updates
D. It automatically sorts the list
B. It requires no traversal
Which operation inserts a new node at the beginning of a singly linked list?
A. pushBack()
B. insertAtHead()
C. insertAtTail()
D. append()
B. insertAtHead()
What does the next pointer in a singly linked list node refer to?
A. The previous node
B. The head node
C. The tail node
D. The next node in the list
D. The next node in the list
Which traversal method is used to visit all nodes in a singly linked list?
A. while (current != null)
B. do-while (current != head)
C. while (current.prev != null)
D. for (int i = 0; i < size; i++)
A. while (current != null)
In a singly linked list, how is traversal typically performed?
A. Using array indices
B. By jumping to tail
C. By following next pointers
D. Using backward pointers
D. Using backward pointers
Which pointer is updated when inserting at the head of a singly linked list?
A. head.prev
B. head.next
C. tail
D. newNode.next
D. newNode.next
What is the default value of the head pointer in a newly created singly linked list?
A. null
B. -1
C. head.next
D. 0
A. null
Which operation deallocates a singly linked list node?
A. remove()
B. new()
C. null()
D. delete()
D. delete()
What is the time complexity of inserting a node at the head of a singly linked list?
A. O(1)
B. O(n)
C. O(log n)
D. O(n²)
A. O(1)
What does the diagram [Pedro] → [Hudas] → null represent?
A. A singly linked list
B. A stack
C. A circular list
D. A doubly linked list
A. A singly linked list
Consider the sequence:
SLLNode snode2 = new SLLNode(“Hudas”);
SLLNode snode1 = new SLLNode(“Pedro”, snode2);
snode1.next = null;
delete(snode2);
What is the effect of delete(snode2)?
A. It removes the head node from the list
B. It deletes the entire list
C. It sets snode2 to null
D. It deallocates the node containing “Hudas” from memory
D. It deallocates the node containing “Hudas” from memory
Which operation allocates a new singly linked list node?
A. delete()
B. new()
C. null()
D. toString()
B. new()
What does toString() return when called on a node?
A. A string describing the node’s info
B. The memory address
C. The pointer value
D. The next node
A. A string describing the node’s info
What happens when you delete the head node in a singly linked list?
A. The list is reversed
B. The head pointer is moved to the next node
C. The head remains unchanged
D. The tail becomes null
B. The head pointer is moved to the next node
What is the result of toString(snode1) if snode1 contains “Pedro”?
A. Pedro → Hudas
B. null
C. “Pedro”
D. “Hudas”
C. “Pedro”
Which operation removes the first node of a singly linked list?
A. deleteFromHead()
B. pop()
C. clear()
D. dequeue()
A. deleteFromHead()
What happens when snode1.next = null is executed?
A. The node becomes the tail
B. The list is reversed
C. The node is deleted
D. The link to the next node is broken
D. The link to the next node is broken
What condition indicates that a singly linked list is empty?
A. size == 0
B. head == tail
C. head == null
D. head.next == null
C. head == null
Which pointer must be updated when inserting a node between two existing nodes in a DLL?
A. Only the new node’s prev pointer
B. No pointers need to be updated
C. Only the new node’s next pointer
D. Both the new node’s next and prev pointers, and the adjacent nodes’ pointers
D. Both the new node’s next and prev pointers, and the adjacent nodes’ pointers
Which traversal method is unique to doubly linked lists?
A. Backward traversal
B. Recursive traversal
C. Circular traversal
D. Forward traversal
A. Backward traversal
What happens if prev is not updated during insertion?
A. The node is deleted
B. The node is skipped during traversal
C. The list becomes singly linked
D. The list becomes circular
B. The node is skipped during traversal
What does a doubly linked list node contain?
A. Data and index
B. Data and two pointers
C. Data and one pointer
D. Only data
B. Data and two pointers