Link List


Question 1
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 n 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?
A
SLLdel is O(1) and DLLdel is O(n)
B
Both SLLdel and DLLdel are O(log(n))
C
Both SLLdel and DLLdel are O(1)
D
SLLdel is O(n) and DLLdel is O(1)
GATE CSE 2023   Data Structure
Question 2
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?
A
The best algorithm for the problem takes \theta(n) time in the worst case.
B
The best algorithm for the problem takes \theta(n \log n) time in the worst case.
C
The best algorithm for the problem takes \theta(n^2) time in the worst case.
D
It is not possible to reverse a singly linked list in O(1) space.
GATE CSE 2022   Data Structure


Question 3
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?
A
Upon execution, the program creates a linked-list of five nodes
B
Upon execution, the program goes into an infinite loop
C
It has a missing returnreturn which will be reported as an error by the compiler
D
It dereferences an uninitialized pointer that may result in a run-time error
GATE CSE 2021 SET-2   Data Structure
Question 4
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?
A
\Theta (n)
B
\Theta (n \log n)
C
\Theta (n^2)
D
\Theta (1)
GATE CSE 2020   Data Structure
Question 5
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 segment 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?
A
X \rightarrow \text { Bwd } \rightarrow \text { Fwd }=X \rightarrow \text { Fwd; } X \rightarrow F w d \rightarrow { Bwd }=X \rightarrow { Bwd; }
B
X \rightarrow \text { Bwd.Fwd }=X \rightarrow \text { Fwd; } X . \text { Fwd } \rightarrow \text { Bwd }=X \rightarrow \text { Bwd; }
C
X . \text { Bwd } \rightarrow \text { Fwd }=X . \text { Bwd; } x \rightarrow { Fwd.Bwd }=X . B w d
D
X \rightarrow \text { Bwd } \rightarrow \text { Fwd }=X \rightarrow \text { Bwd; } X \rightarrow \text{ Fwd } \rightarrow \text { Bwd }=X \rightarrow \text { Fwd; }
ISRO CSE 2018   Data Structure


There are 5 questions to complete.

7 thoughts on “Link List”

Leave a Comment