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?

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?

SLLdel is O(1) and DLLdel is O(n) | |

Both SLLdel and DLLdel are O(log(n)) | |

Both SLLdel and DLLdel are O(1) | |

SLLdel is O(n) and DLLdel is O(1) |

Question 1 Explanation:

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?

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 \theta(n) time in the worst case. | |

The best algorithm for the problem takes \theta(n \log n) time in the worst case. | |

The best algorithm for the problem takes \theta(n^2) time in the worst case. | |

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

Question 2 Explanation:

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?Upon execution, the program creates a linked-list of five nodes | |

Upon execution, the program goes into an infinite loop | |

It has a missing returnreturn which will be reported as an error by the compiler | |

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

Question 3 Explanation:

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?

\Theta (n) | |

\Theta (n \log n) | |

\Theta (n^2) | |

\Theta (1) |

Question 4 Explanation:

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?X \rightarrow \text { Bwd } \rightarrow \text { Fwd }=X \rightarrow \text { Fwd; } X \rightarrow F w d \rightarrow { Bwd }=X \rightarrow { Bwd; } | |

X \rightarrow \text { Bwd.Fwd }=X \rightarrow \text { Fwd; } X . \text { Fwd } \rightarrow \text { Bwd }=X \rightarrow \text { Bwd; } | |

X . \text { Bwd } \rightarrow \text { Fwd }=X . \text { Bwd; } x \rightarrow { Fwd.Bwd }=X . B w d | |

X \rightarrow \text { Bwd } \rightarrow \text { Fwd }=X \rightarrow \text { Bwd; } X \rightarrow \text{ Fwd } \rightarrow \text { Bwd }=X \rightarrow \text { Fwd; } |

Question 5 Explanation:

There are 5 questions to complete.

Pls add DARK MODE:)

if possible pls add UGC NET topic wise question.

Use dark.mode chrome extension