1
GATE CSE 2008
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 2008
MCQ (Single Correct Answer)
+1
-0.3
Which of the following is TRUE?
A
The cost of searching an AVL tree is θ (log n) but that of a binary search tree is O(n)
B
The cost of searching an AVL tree is θ (log n) but that of a complete binary tree is θ (n log n)
C
The cost of searching a binary search tree is O (log n ) but that of an AVL tree is θ(n)
D
The cost of searching an AVL tree is θ (n log n) but that of a binary search tree is O(n)
3
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
The following three are known to be the preorder, inorder and postorder sequences of a binary tree. But it is not known which is which. MBCAFHPYK KAMCBYPFH MABCKYFPH Pick the true statement from the following.
A
I and II are preorder and inorder sequences, respectively
B
I and III are preorder and postorder sequences, respectively
C
II is the inorder sequence, but nothing more can be said about the other two sequences
D
II and III are the preorder and inorder sequences, respectively
4
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
A Binary Search Tree (BST) stores values in the range 37 to 573. Consider the following sequence of keys.
I. 81, 537, 102, 439, 285, 376, 305
II. 52, 97, 121, 195, 242, 381, 472
III. 142, 248, 520, 386, 345, 270, 307
IV. 550, 149, 507, 395, 463, 402, 270
Suppose the BST has been unsuccessfully searched for key 273. Which all of the above sequences list nodes in the order in which we could have encountered them in the search?
A
II and III only
B
I and III only
C
III and IV only
D
III only
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
CBSE
Class 12