Linked Lists questions

Q39

GATE CS 2026 CS-1Linear Data StructuresMCQ2 marks−2/3 if wrong
Consider the following code snippet in C language that computes the number of nodes in a non-empty singly linked list pointed to by the pointer variable head.
struct node{
 int elt;
 struct node *next;
};

int getListSize (struct node *head)
{
 if( E1 ) return 1;
 return E2;
}
Which one of the following options gives the correct replacements for the expressions E1 and E2?
Show answer without attempting

Answer: B

Q62

GATE CS 2025 CS-1Linear Data StructuresNAT2 marks
Let LIST be a datatype for an implementation of linked list defined as follows:
typedef struct list {
 int data;
 struct list *next;
} LIST;
Suppose a program has created two linked lists, L1 and L2, whose contents are given in the figure below (code for creating L1 and L2 is not provided here). L1 contains 9 nodes, and L2 contains 7 nodes.

Consider the following C program segment that modifies the list L1. The number of nodes that will be there in L1 after the execution of the code segment is ________ . (Answer in integer)
int find (int query, LIST *list) {
 while (list != NULL){
 if(list->data == query) return 1;
 list = list->next;
 }
 return 0;
}
int main () {

 ptr1=L1; ptr2=L2;
 while (ptr1->next != NULL){
 query = ptr1->next->data;
 if (find (query, L2))
 ptr1->next = ptr1->next->next;
 else ptr1 = ptr1->next;
 }

 return 0;
}
Question figure
Show answer without attempting

Answer: 5

Q38

GATE CS 2025 CS-2Linear Data StructuresMCQ2 marks−2/3 if wrong
A meld operation on two instances of a data structure combines them into one single instance of the same data structure. Consider the following data structures:

P: Unsorted doubly linked list with pointers to the head node and tail node of the list.
Q: Min-heap implemented using an array.
R: Binary Search Tree.

Which ONE of the following options gives the worst-case time complexities for meld operation on instances of size nn of these data structures?
Show answer without attempting

Answer: A

Q13

GATE CS 2023 CSLinear Data StructuresMCQ1 mark−1/3 if wrong
Let SLLdel be a function that deletes a node in a singly-linked list given a pointer to the node and a pointer to the head of the list. Similarly, let DLLdel be another function that deletes a node in a doubly-linked list given a pointer to the node and a pointer to the head of the list.
Let nn denote the number of nodes in each of the linked lists. Which one of the following choices is TRUE about the worst-case time complexity of SLLdel and DLLdel?
Show answer without attempting

Answer: D

Q15

GATE CS 2022 CSLinear Data StructuresMCQ1 mark−1/3 if wrong
Consider the problem of reversing a singly linked list. To take an example, given the linked list below,

head -> [a] -> [b] -> [c] -> [d] -> [e] -> NULL

the reversed linked list should look like

head -> [e] -> [d] -> [c] -> [b] -> [a] -> NULL

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

Answer: A

Q16

GATE CS 2020 CSLinear Data StructuresMCQ1 mark−1/3 if wrong
What is the worst case time complexity of inserting nn elements into an empty linked list, if the linked list needs to be maintained in sorted order?
Show answer without attempting

Answer: C

Q3

GATE CS 2018 CSLinear Data StructuresMCQ1 mark−1/3 if wrong
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 nn 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.

Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure?
Question figure
Show answer without attempting

Answer: B

Q8

GATE CS 2017 CS-1Linear Data StructuresMCQ1 mark−1/3 if wrong
Consider the C code fragment given below.
typedef struct node {
    int data;
    node* next;
} node;

void join(node* m, node* n) {
    node* p = n;
    while (p->next != NULL) {
        p = p->next;
    }
    p->next = m;
}
Assuming that mm and nn point to valid NULL-terminated linked lists, invocation of join will
Show answer without attempting

Answer: B

Q13

GATE CS 2017 CS-2Linear Data StructuresMCQ1 mark−1/3 if wrong
A circular queue has been implemented using a singly linked list where each node consists of a value and a single pointer pointing to the next node. We maintain exactly two external pointers FRONT and REAR pointing to the front node and the rear node of the queue, respectively. Which of the following statements is/are CORRECT for such a circular queue, so that insertion and deletion operations can be performed in O(1)O(1) time?

I. Next pointer of front node points to the rear node.
II. Next pointer of rear node points to the front node.
Show answer without attempting

Answer: B

Q15

GATE CS 2016 CS-2Linear Data StructuresMCQ1 mark−1/3 if wrong
NN 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)\Theta(N) delete, O(log⁡N)O(\log N) insert, O(log⁡N)O(\log N) find, and Θ(N)\Theta(N) decrease-key. What is the time complexity of all these operations put together?
Show answer without attempting

Answer: C

0/100 correct0 marks

Related topics in Linear Data Structures