NEW
Font size
WorksheetsLinkedList Java
Total questions: 33
Worksheet time: 23mins
Linked list is generally considered as an example of _________ type of memory allocation.
static
compile time
dynamic
none of these
In Linked list implementation, a node carries information regarding _______.
Data
Link
Data and Link
Node
Linked list data structure usage offers considerable saving in
Computational time
Space utilization
Space utilization and Computational time
None of the above
What is the time complexity to count the number of elements in the linked list?
O(n)
O(1)
O(log n)
None of the above
Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?
a. Insertion at the front of the linked list
b.Insertion at the end of the linked list
c.Deletion of the front node of the linked list
d. Deletion of the last node of the linked list
a and c
a and b
b and d
d and a
The doubly linked list would have how many fields in a node?
1
2
3
4
How many null pointers exists in a circular linked list?
0
1
2
3
What is the condition to check whether linked
list is empty
Head->next==Null
Head->next->next==Null
temp->next==Null
Head==Null
Which of these is a self-referential structure?
Linked-List
Array
Node
None of the above
What would the next of the last node of a circular linked list return?
head
tail
null
none of the above
What is the best and worst-case time complexity for searching for a value in a Linked List?
O(1) and O(log n)
O(1) and O(1)
O(1) and O(n^2)
O(1) and O(n)
How do you insert an element at the beginning of the list?
public void insertBegin(Node node)
{
node->next=head;
head = node;
}
public void insertBegin(Node node)
{
head = node;
node->next=head;
}
public void insertBegin(Node node)
{
head = node;
}
None
What type of linkedlist is represented in the image
singly linkedlist
doubly linkedlist
circular singly linkedlist
circular doubly linkedlist
class Test {
public static void main(String args[]) {
int arr[2];
System.out.println(arr[0]);
System.out.println(arr[1]);
}
}
0
0
garbage value
garbage value
Compiler Error
Exception
public class Main {
public static void main(String args[]) {
int arr[][] = new int[4][];
arr[0] = new int[1];
arr[1] = new int[2];
arr[2] = new int[3];
arr[3] = new int[4];
int i, j, k = 0;
for (i = 0; i < 4; i++) {
for (j = 0; j < i + 1; j++) {
arr[i][j] = k;
k++;
}
}
for (i = 0; i < 4; i++) {
for (j = 0; j < i + 1; j++) {
System.out.print(" " + arr[i][j]);
k++;
}
System.out.println();
}
}
}
Compiler Error
0
1 2
3 4 5
6 7 8 9
0
0 0
0 0 0
0 0 0 0
9
7 8
4 5 6
0 1 2 3
What would be the time complexity of adding an element to the middle of a linked list?
O(n)
O(1)
O(n^2)
None of the above
Which node’s data will be printed when
“temp =temp->next” is executed 3 times and the initial value of temp is temp=head
Null
9
27
46
In the above image what will be printed when Head->next->data?
83
9
27
Error
In the above image what will be printed when Head->next->next->data is displayed?
83
9
27
Error
Which operation is not typically supported by a LinkedList in Java?
Sorting the list in place
Removing an element from the beginning
Adding an element at the end
Accessing an element by index
When an ArrayList in Java reaches its capacity and you add one more element, which of the following best describes what happens internally?
Java simply allocates one extra slot in the same array.
The old array is extended in place without reallocation.
A new array is created (1.5× old size), elements are copied, and reference is updated.
A linked list node is appended to the current structure.
Element Removal — Hidden Cost
Consider:
List<Integer> list = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5));
list.remove(2);
What happens internally when remove(2) is called?
Element at index 2 is nullified; array size remains same.
Element at index 2 is removed; subsequent elements are shifted left.
The entire array is reallocated.
The operation is O(1) as it just changes a pointer.
Random Access & Iterator Behavior
You have:
List<String> list = new LinkedList<>(List.of("A", "B", "C", "D")); list.get(3);
Which statement is true?
Operation executes in O(1) as LinkedList supports direct indexing.
It traverses nodes from head to index 3 sequentially — O(n).
It converts to an array internally for faster access.
The call fails at runtime because LinkedList doesn’t implement List.
You’re designing a playlist manager where songs are often added and removed from the middle of the list. Occasional random access is needed but not frequent.
Which data structure gives the best balance?
Array
ArrayList
LinkedList
Vector
Which of the following correctly reverses a singly linked list iteratively and returns the new head?
Which of the following recursive functions correctly reverses a singly linked list and returns the new head?
ListNode reverse(ListNode head) {
if (head == null || head.next == null)
return head;
ListNode rest = reverse(head.next);
head.next.next = head;
head.next = null;
return rest;
}
Output?
1 2 3 4
4 3 2 1
1 3 2 4
Compilation error
