• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Linked List Data Structure with Answers

Question 11

What are the time complexities of finding 8th element from beginning and 8th element from end in a singly linked list? Let n be the number of nodes in linked list, you may assume that n > 8.

  • O(1) and O(n)

  • O(1) and O(1)

  • O(n) and O(1)

  • O(n) and O(n)

Question 12

Is it possible to create a doubly linked list using only one pointer with every node.

  • Not Possible

  • Yes, possible by storing XOR of addresses of previous and next nodes.

  • Yes, possible by storing XOR of current node and next node

  • Yes, possible by storing XOR of current node and previous node

Question 13

Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?

  • Possible if X is not last node. Use following two steps (a) Copy the data of next of X to X. (b)Update the pointer of node X to the node after the next node. Delete next of X.

  • Possible if size of linked list is even.

  • Possible if size of linked list is odd

  • Possible if X is not first node. Use following two steps (a) Copy the data of next of X to X. (b) Delete next of X.

Question 14

Which of the following is an application of XOR-linked lists?

  • Implementing stacks

  • Implementing queues

  • Memory-efficient linked list representation

  • Caching data structures

Question 15

Consider the following function to traverse a linked list. 

C
void traverse(struct Node *head)
{
   while (head->next != NULL)
   {
       printf(\"%d  \", head->data);
       head = head->next;
   }
}

Which of the following is FALSE about above function?

  • The function may crash when the linked list is empty

  • The function doesn\'t print the last node when the linked list is not empty

  • The function is implemented incorrectly because it changes head

  • None of the above

Question 16

N items are stored in a sorted doubly linked list. For a delete operation, a pointer is provided to the record to be deleted. For a decrease-key operation, a pointer is provided to the record on which the operation is to be performed. An algorithm performs the following operations on the list in this order: Θ(N) delete, O(log N) insert, O(log N) find, and Θ(N) decrease-key What is the time complexity of all these operations put together?

  • O(Log2N)

  • O(N)

  • O(N Log N)

  • Θ(N2 Log N)

Question 17

What are the application(s) of linked list?

  • Implementation of stacks and queues.

  • Maintaining a directory of names

  • None of the above

  • Both a and b

Question 18

The concatenation of two lists is to be performed in O(1) time. Which of the following implementations of a list should be used?

  • singly linked list

  • doubly linked list

  • circular doubly linked list

  • array implementation of lists

Question 19

Consider the following piece of \'C\' code fragment that removes duplicates from an ordered list of integers.

Node  *remove-duplicates(Node *head, int *j)
{
Node *t1, *t2;
*j=0;
t1 = head;
if (t1! = NULL) t2 = t1 →next;
else return head;
*j = 1;
if(t2 == NULL)
return head;
while t2 != NULL)
{
if (t1.val != t2.val) --------------------------→ (S1)
{
(*j)++; t1 -> next = t2; t1 = t2: ----------→ (S2)
}
t2 = t2 →next;
}
t1 →next = NULL;
return head;
}

Assume the list contains n elements (n≥2) in the following questions. a). How many times is the comparison in statement S1 made? b). What is the minimum and the maximum number of times statements marked S2 get executed? c). What is the significance of the value in the integer pointed to by j when the function completes?

    • (a). n-1 times, since comparison is pairwise for n elements.
    • (b). maximum : n-1 for all distinct elements, minimum: 0 for all same elements.
    • (C). j keeps count of distinct nodes in the list.
    • (a). n times, since comparison is pairwise for n elements.
    • (b). maximum : n-1 for all distinct elements, minimum: 0 for all same elements.
    • (C). j keeps count of distinct nodes in the list.
    • (a). n-1 times, since comparison is pairwise for n elements.
    • (b). maximum : n-1 for all distinct elements, minimum: 1 for all same elements.
    • (C). j keeps count of distinct nodes in the list.
  • None of the above

Question 20

Suppose there are two singly linked lists both of which intersect at some point and become a single linked list. The head or start pointers of both the lists are known, but the intersecting node and lengths of lists are not known. What is worst case time complexity of optimal algorithm to find intersecting node from two intersecting linked lists?

  • Θ(n*m), where m, n are lengths of given lists

  • Θ(n^2), where m>n and m, n are lengths of given lists

  • Θ(m+n), where m, n are lengths of given lists

  • Θ(min(n, m)), where m, n are lengths of given lists

There are 42 questions to complete.

Last Updated :
Take a part in the ongoing discussion