Time Left - 15:00 mins

# GATE CS 2021 : Data Structure & Programming Quiz 3 (App update required to attempt this test)

Attempt now to get your rank among 1135 students!

Question 1

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

Question 2

What is the minimum runtime to reverse a doubly linked list?

Question 3

Consider a doubly linked list. The doubly linked list contains pointers to next nodes and to previous nodes as well. Hence a node in doubly linked list contains a data and two pointers. Our task is to insert a new node at the second last position of the linked list. Find the number of pointers that needs to be updated in doubly linked list to do so __________.

Question 4

Consider the following code which is implemented on a linked list :
Struct node *ABC(Struct node *S)
{
Struct node *p,*q;
p = q = S;
while(q!=null && q->next !=null && q->next->next !=null)
{
p = p->next;
q = q->next->next;
}
return p;
}
What does the code return when the head of a linked list is passed as an argument to the code ?

Question 5

The following C function takes a simply-linked list as input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some part of the code is left blank.
typedef struct node {
int value;
struct node *next;
} Node;
Node *move_to_front(Node *head) {
Node *p, *q;
if ((head = = NULL : | | (head -> next = = NULL)) return head;
q = NULL; p = head;
while (p -> next !=NULL) {
q = P;
p = p -> next;
}
____________________________