Following C code is for detecting cycle in the linked list. Choose the correct option that can be used in postion 1, 2 and 3.(Note: Number of nodes can be even or odd).

int detectAndRemoveLoop(struct node *list)

{

            struct node *slow_p = list, *fast_p = list;

            while (position 1.____________)

            {

            slow_p = slow_p->next;

            fast_p = (position 2._________)

/* If slow_p and fast_p meet at some point then there

                        is a loop */

                        if (postion 3________________)

                        {

                        removeLoop(slow_p, list);

/* Return 1 to indicate that loop is found */

                        return 1;

                        }

             }

}

1

1) slow_p && fast_p , 2) fast_p->next->next, 3) slow_p==fast_p

2

1) slow_p && fast_p , 2) fast_p->next, 3) slow_p!=fast_p

3

1)slow_p && fast_p && fast_p->next , 2)fast_p->next->next, 3)slow_p!=fast_p 

4

1)slow_p && fast_p && fast_p->next, 2)fast_p->next->next, 3)slow_p==fast_p

Sponsored

hivanix.in

Visit

This quiz is brought to you by hivanix.in

🌐 Web App Development

Quick Navigation