GATEverse
← GATE CSE 2025 Set 1

Q52

NAT2 marks

Let LIST\mathrm{LIST} be a datatype for an implementation of linked list defined as follows: typedef struct list { int data; struct list *next; } LIST; Suppose a program has created two linked lists, L1L1 and L2L2, whose contents are given in the figure below (code for creating L1L1 and L2L2 is not provided here). L1L1 contains 99 nodes, and L2L2 contains 77 nodes. Consider the following C program segment that modifies the list L1L1. The number of nodes that will be there in L1L1 after the execution of the code segment is __________. (Answer in integer)

Figure 1

int find (int query, LIST *list) { while (list != NULL) { if(list->data == query) return 1 ; list = list->next; } return 0 ; } int main (){ ... ... ... ptr1=L1; ptr2=L2; while (ptr1->next != NULL){ query = ptr1->next->data; if (find (query, L2)) ptr1->next = ptr1->next->next; else ptr1 = ptr1->next; } ... .... ... return 0; }

Sign in to save attempts.

Loading…