1
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
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; 
    } 
}
A
1,2,3,4,5,6,7
B
2,1,4,3,6,5,7
C
1,3,2,5,4,7,6
D
2,3,4,5,6,7,1
2
GATE CSE 2005
MCQ (Single Correct Answer)
+1
-0.3
The numbers 1, 2, ........, n are inserted in a binary search tree in some order. In the resulting tree, the right subtree of the root contains p nodes. The first number to be inserted in the tree must be
A
p
B
p + 1
C
n – p
D
n – p + 1
3
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Postorder traversal of a given binary search tree T produces the following sequence of keys 10, 9, 23, 22, 27, 25, 15, 50, 95, 60, 40, 29 Which one of the following sequences of keys can be the result of an inorder traversal of the tree T?
A
9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95
B
9, 10, 15, 22, 40, 50, 60, 95, 23, 25, 27, 29
C
29, 15, 9, 10, 25, 22, 23, 27, 40, 60, 50, 95
D
95, 50, 60, 40, 27, 23, 22, 25, 10, 9, 15, 29
4
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
In a complete k-ary tree, every internal node has exactly k children. The number of leaves in such a tree with n internal nodes is
A
nk
B
(n – 1)k + 1
C
n(k – 1) + 1
D
n(k – 1)
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
CBSE
Class 12