• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Linked List Data Structure with Answers

Question 31

A doubly linked list is declared as

struct Node {
int Value;
struct Node *Fwd;
struct Node *Bwd;
);

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 32

Consider a singly linked list of the form where F is a pointer to the first element in the linked list and L is the pointer to the last element in the list. The time of which of the following operations depends on the length of the list?

  • Delete the last element of the list

  • Delete the first element of the list

  • Add an element after the last element of the list

  • Interchange the first two elements of the list

Question 33

Consider the following ANSI C program:

#include < stdio.h >
#include < stdlib.h >
struct Node{
int value;
struct Node *next;};
int main( ) {
struct Node *boxE, *head, *boxN; int index=0;
boxE=head= (struct Node *) malloc(sizeof(struct Node));
head → value = index;
for (index =1; index<=3; index++){
boxN = (struct Node *) malloc (sizeof(struct Node));
boxE → next = boxN;
boxN → value = index;
boxE = boxN; }
for (index=0; index<=3; index++) {
printf(“Value at index %d is %d\\n”, index, head → value);
head = head → next;
printf(“Value at index %d is %d\\n”, index+1, head → value); } }

Which one of the following statements below is correct about the program?

  • Upon execution, the program creates a linked-list of five nodes

  • Upon execution, the program goes into an infinite loop

  • It has a missing return which will be reported as an error by the compiler

  • It dereferences an uninitialized pointer that may result in a run-time error

Question 34

Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?

  • Insertion Sort

  • Quick Sort

  • Heap Sort

  • Merge Sort

Question 35

In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is (GATE CS 2002)

  • log(2*n)

  • n/2

  • log(2*n) -1

  • n

Question 36

Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best known algorithm to delete the node Q from the list?

  • O(n)

  • O(log2 n)

  • O(logn)

  • O(1)

Question 37

What is the worst case time complexity of inserting n elements into an empty linked list, if the linked list needs to be maintained in sorted order ?

  • Θ(n)

  • Θ(n log n)

  • Θ(n2)

  • Θ(1)

Question 38

Consider the following conditions:

 (a)The solution must be feasible, i.e. it must satisfy all the supply and demand constraints. 

(b)The number of positive allocations must be equal to m1n21, where m is the number of rows and n is the number of columns. 

(c)All the positive allocations must be in independent positions. 

The initial solution of a transportation problem is said to be non-degenerate basic feasible solution if it satisfies: Codes:

  • (a) and (b) only

  • (a) and (c) only

  • (b) and (c) only

  • (a), (b) and (c)

Question 39

Consider the following statements:

i.   First-in-first out types of computations are efficiently supported by STACKS.
ii. Implementing LISTS on linked lists is more efficient than implementing LISTS on an array for almost all the basic LIST operations.
iii. Implementing QUEUES on a circular array is more efficient than implementing QUEUES on a linear array with two indices.
iv. Last-in-first-out type of computations are efficiently supported by QUEUES.

Which of the following is correct?

  • (ii) is true

  • (i) and (ii) are true

  • (iii) is true

  • (ii) and (iv) are true

Question 40

Consider the problem of reversing a singly linked list. To take an example, given the linked list below, 

the reversed linked list should look like 

Which one of the following statements is TRUE about the time complexity of algorithms that solve the above problem in O(1) space?

  • The best algorithm for the problem takes [Tex]\theta (n)    [/Tex] time in the worst case

  • The best algorithm for the problem takes [Tex]\theta(nlogn)    [/Tex] time in the worst case. 

  • The best algorithm for the problem takes [Tex]\theta(n^{2})    [/Tex] time in the worst case

  • It is not possible to reverse a singly linked list in O(1) space. 

There are 42 questions to complete.

Last Updated :
Take a part in the ongoing discussion