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;
}
}Related Programming & Data Structures PYQs
Choose the correct option to fill ?1 and ?2 so that the program below prints an input string in reverse order. Assume that the inp…
You are given the postorder traversal, P, of a binary search tree on the n elements 1, 2, ..., n. You have to determine the unique…
Consider a hash table of size seven, with starting index zero, and a hash function h(x) = (3x + 4) mod 7. Assuming the hash table …
Let n be an odd number greater than 100. Consider a binary minheap with n elements stored in an array P whose index starts from 1.…
Consider a hash table P[0, 1, ..., 10] that is initially empty. The hash table is maintained using open addressing with linear pro…
The height of a binary tree is the number of edges in the longest path from the root to a leaf in the tree. The maximum possible h…
Free account benefits
Turn practice into measurable progress
Public PYQs and reference pages stay free. Sign in when you want GATEverse to remember what you studied and guide what to practise next.