Top MCQs on Linked List Data Structure with Answers

Last Updated :
Discuss
Comments

Question 1

A doubly linked list is declared as

C++
struct Node {
       int Value;
       struct Node *Fwd;
       struct Node *Bwd;
);
C
// Struct definition in C
struct Node {
    int Value;
    struct Node *Fwd;
    struct Node *Bwd;
};
Java
// Struct definition in Java
class Node {
    int Value;
    Node Fwd;
    Node Bwd;
}
Python
# Class definition in Python
class Node:
    def __init__(self, value):
        self.Value = value
        self.Fwd = None
        self.Bwd = None
JavaScript
// Class definition in JavaScript
class Node {
    constructor(value) {
        this.Value = value;
        this.Fwd = null;
        this.Bwd = null;
    }
}

Where Fwd and Bwd represent forward and backward link to the adjacent elements of the list. Which of the following segments of code deletes the node pointed to by X from the doubly linked list, if it is assumed that X points to neither the first nor the last node of the list?

  • X->Bwd->Fwd = X->Fwd; X->Fwd->Bwd = X->Bwd ;

  • X->Bwd.Fwd = X->Fwd ; X.Fwd->Bwd = X->Bwd ;

  • X.Bwd->Fwd = X.Bwd ; X->Fwd.Bwd = X.Bwd ;

  • X->Bwd->Fwd = X->Bwd ; X->Fwd->Bwd = X->Fwd;

Question 2

A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the queue. Let 'enqueue' be implemented by inserting a new node at the head, and 'dequeue' be implemented by deletion of a node from the tail.

Queue


Which one of the following is the time complexity of the most time-efficient implementation of 'enqueue' and 'dequeue, respectively, for this data structure?

  • Θ(1), Θ(1)

  • Θ(1), Θ(n)

  • Θ(n), Θ(1)

  • Θ(n), Θ(n)

Question 3

In a doubly linked list, the number of pointers affected for an insertion operation will be

  • 5

  • 0

  • 1

  • None of these

Question 4

Consider an implementation of unsorted single linked list. Suppose it has its representation with a head and a tail pointer (i.e. pointers to the first and last nodes of the linked list). Given the representation, which of the following operation can not be implemented in O(1) time ?

  • Insertion at the front of the linked list.

  • Insertion at the end of the linked list.

  • Deletion of the front node of the linked list.

  • Deletion of the last node of the linked list.

Question 5

Consider a single linked list where F and L are pointers to the first and last elements respectively of the linked list. The time for performing which of the given operations depends on the length of the linked list?

F->1->2->3->L

  • Delete the first element of the list

  • Interchange the first two elements of the list

  • Delete the last element of the list

  • Add an element at the end of the list

Question 6

The following steps in a linked list

p = getnode()
info (p) = 10
next (p) = list
list = p

result in which type of operation?

  • pop operation in stack

  • removal of a node

  • inserting a node at beginning 

  • modifying an existing node

Question 7

In DNA sequence alignment, which string-matching algorithm is commonly used to identify similarities between two DNA sequences efficiently?

  • Rabin-Karp algorithm

  • Knuth-Morris-Pratt algorithm

  • Z function

  • None of the above

Question 8

Which of the following operations is performed more efficiently by doubly linked list than by linear linked list?

  • Deleting a node whose location is given

  • Searching an unsorted list for a given item

  • Inserting a node after the node with a given location

  • Traversing the list to process each node

Question 9

The time required to search an element in a linked list of length n is

  • O (log n)

  • O (n)

  • O (1)

  • O (n2)

Question 10

The minimum number of fields with each node of doubly linked list is

  • 1

  • 2

  • 3

  • 4

There are 39 questions to complete.

Take a part in the ongoing discussion