GATEverse
← GATE CSE 1997

Q18

MCQMarks unknown

Consider the following piece of 'C' code fragment that removes duplicates from an ordered list of integers. Node *remove-duplicates (Node* head, int *j) { Node *t1, *t2; *j=0; t1 = head; if (t1! = NULL) t2 = t1 ->next; else return head; *j = 1; if(t2 == NULL) return head; while (t2 != NULL) { if (t1.val != t2.val) ----------------> (S1) { (*j)++; t1 -> next = t2; t1 = t2; -----> (S2) } t2 = t2 ->next; } t1 -> next = NULL; return head; } Assume the list contains nn elements (n≥2n\geq 2) in the following questions.

Sign in to save attempts.

Loading…