1
GATE CSE 2008
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program that attempts to locate an element x in an array Y[] using binary search. The program is erroneous.
1.   f(int Y[10], int x) {
2.     int i, j, k;
3.     i = 0; j = 9;
4.     do {
5.             k =  (i + j) /2;
6.             if( Y[k] < x)  i = k; else j = k;
7.         } while(Y[k] != x && i < j);
8.     if(Y[k] == x) printf ("x is in the array ") ;
9.     else printf (" x is not in the array ") ;
10.  }
The correction needed in the program to make it work properly is
A
Change line 6 to: if (Y[k]
B
Change line 6 to: if (Y[k]
C
Change line 6 to: if (Y[k]
D
Change line 7 to: } while ((Y[k]==x)&&(i
2
GATE CSE 1996
MCQ (Single Correct Answer)
+2
-0.6
A binary search tree is generated by inserting in order the following integers:

50, 15, 62, 5, 20, 58, 91, 3, 8, 37, 60, 24

The number of nodes in the left subtree and right subtree of the root respectively is
A
(4, 7)
B
(7, 4)
C
(8, 3)
D
(3, 8)
3
GATE CSE 1991
Subjective
+2
-0
Obtain the optimal binary search tree with equal probabilities for the identifier set (a1, a2, a3) = ( if, stop, while)
GATE CSE Subjects
Software Engineering
Web Technologies
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12