Question 1 |
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 1 Explanation:
Question 2 |
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 2 Explanation:
Question 3 |
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 3 Explanation:
Question 4 |
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 4 Explanation:
Question 5 |
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 5 Explanation:
Question 6 |
In a doubly linked list the number of pointers affected for an insertion operation will be
4 | |
0 | |
1 | |
Depends on the nodes of doubly linked list |
Question 6 Explanation:
Question 7 |
Given two statements
Insertion of an element should be done at the last node of the circular list
Deletion of an element should be done at the last node of the circular list
Insertion of an element should be done at the last node of the circular list
Deletion of an element should be done at the last node of the circular list
Both are true | |
Both are false | |
First is false and second is true | |
None of the above |
Question 7 Explanation:
Question 8 |
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 m and n point to valid NULL- terminated linked lists, invocation of join willappend list m to the end of list n for all inputs. | |
either cause a null pointer dereference or append list m to the end of list n. | |
cause a null pointer dereference for all inputs. | |
append list n to the end of list m for all inputs. |
Question 8 Explanation:
Question 9 |
N 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: \Theta(N) \; delete , O(logN) \; insert , O(logN) \; find , and \Theta(N) \; decrease-key. What is the time complexity of all these operations put together?
An algorithm performs the following operations on the list in this order: \Theta(N) \; delete , O(logN) \; insert , O(logN) \; find , and \Theta(N) \; decrease-key. What is the time complexity of all these operations put together?
O(log^{2}N) | |
O(N) | |
O(N^{2}) | |
\Theta (N^{2} logN) |
Question 9 Explanation:
Question 10 |
An unordered list contains n distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is
\Theta (n log n) | |
\Theta (n) | |
\Theta (log n) | |
\Theta (1) |
Question 10 Explanation:
There are 10 questions to complete.
Pls add DARK MODE:)
if possible pls add UGC NET topic wise question.