Time Left - 15:00 mins

GATE 2019 - P&DS Quiz-4 (Linked List )

Attempt now to get your rank among 1047 students!

Question 1

When are linked lists considered linear data structures?

Question 2

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

Question 3

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 will

Question 4

Consider the linked list of integers represented by the following diagram.

Run the following code with the above list of integers.
Node* Prev,*nodeToDele;
Prev=head;
nodeToDele item=28
nodeToDele next=Prev next;
Prev next=nodeToDele
Assume the following structure is used to create a node in the list.
Struct Node
{
int item;
Node*next;
}
Which of the following is the effect of code.

Question 5

A circular queue has been implemented using a single 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 operation can be performed in 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.

Question 6

What is the use of “struct node* BuildOneTwoThree();” ?
struct node* BuildOneTwoThree()
{
node* head = NULL;
node* second = NULL;
node* third = NULL;
head = (node*)malloc(sizeof(struct node));
second =(node*) malloc(sizeof(struct node));
third = (node*)malloc(sizeof(struct node));
head->data = 1;
head->next = second;
second->data = 2;
second->next = third;
third->data = 3;
third->next = NULL;
return head;
}
  • 1047 attempts
  • 2 upvotes
  • 12 comments
Apr 6GATE & PSU CS