• Data Structure Reference

• Other Reference

# Data Structure MCQ - Linked List

This section focuses on the "Linked List" of the Data Structure. These Multiple Choice Questions (mcq) should be practiced to improve the Data Structure skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. What does the following function do for a given Linked List with first node as head?

```
void fun1(struct node* head)
{
return;
}
```

A. Prints all nodes of linked lists
B. Prints all nodes of linked list in reverse order
C. Prints alternate nodes of Linked List
D. Prints alternate nodes in reverse order

2. A linear collection of data elements where the linear node is given by means of pointer is called?

B. node list
C. primitive list
D. None of these

3. What is the time complexity to count the number of elements in the linked list?

A. O(1)
B. O(n)
C. O(logn)
D. None of the mentioned

4. What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?

A. O(1)
B. O(n)
C. θ (n)
D. θ (1)

5. What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6

```
void fun(struct node* start)
{
if(start == NULL)
return;
printf("%d ", start->data);
if(start->next != NULL )
fun(start->next->next);
printf("%d ", start->data);
}
```

A. 1 4 6 6 4 1
B. 1 3 5 1 3 5
C. 1 2 3 5
D. 1 3 5 5 3 1

6. What is the functionality of the following piece of code?

```
public int function(int data)
{
Node temp = head;
int var = 0;
while(temp != null)
{
if(temp.getData() == data)
{
return var;
}
var = var+1;
temp = temp.getNext();
}
return Integer.MIN_VALUE;
}
```

A. Find and delete a given element in the list
B. Find and return the given element in the list
C. Find and return the position of the given element in the list
D. Find and insert a new element in the list

7. Linked lists are not suitable to for the implementation of?

A. Insertion sort
C. Polynomial manipulation
D. Binary search

8. In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is

A. log 2 n
B. n/2
C. log 2 n – 1
D. n

9. Which of these is an application of linked lists?

A. To implement file systems
B. For separate chaining in hash-tables
C. To implement non-binary trees
D. All of the mentioned

10. In circular linked list, insertion of node requires modification of?

A. One pointer
B. Two pointer
C. Three pointer
D. None