Home / MCQ Bank / Computer
Computer Introduction To Data Structures Difficulty: Medium

The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7 in the given order. What will be the contents of the list after the function completes execution? struct node { int value; struct node *next; }; void rearrange(struct node *list) { struct node *p, * q; int temp; if ((!list) || !list->next) return; p = list; q = list->next; while(q) { temp = p->value; p->value = q->value; q->value = temp; p = q->next; q = p?p->next:0; } }

Select the correct option to test your answer:

More Computer Questions

Why the below pseudo code where x is a value, wt is weight factor and t is root node can't insert? WeightBalanceTreeNode insert(int x, int wt, WeightBalanceTreeNode k) : if (k == null) k = new WeightBalanceTreeNode(x, wt, null, null) else if (x < t.element) : k.left = insert (x, wt, k.left) if (k.left.weight < k.weight) k = rotateWithRightChild (k) else if (x > t.element) : k.right = insert (x, wt, k.right) if (k.right.weight < k.weight) k = rotateWithLeftChild (k) Which keyword is used for sorting the data in descending order in Mysql? If member does not implement serialization, which exception would be thrown? What data structure is used to implement a system where operations must be performed on the middle element frequently? What is a common use case of the Bellman-Ford algorithm?