1
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the pseudocode below is invoked as height (root) to compute the height of a binary tree rooted at the tree pointer root.
int height (treeptr n) 
  { if (n== NULL) return -1; 
  if (n-> left == NULL) 
  if (n-> right ==NULL) return 0; 
  else return B1 ;             // Box 1 
  else {h1 = height (n -> left); 
      if (n -> right == NULL) return (1 + h1); 
      else {h2 = height (n -> right); 
          return B2 ;          // Box 2 
          } 
      } 
}
The appropriate expression for the two boxes B1 and B2 are
A
B1 : (1 + height(n->right)), B2 : (1 + max(h1,h2))
B
B1 : (height(n->right)), B2 : (1 + max(h1,h2))
C
B1 : height(n->right), B2 : max(h1,h2)
D
B1 : height(n->right), B2 : max(h1,h2)
2
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operations are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
A
full: (REAR+1)
mod n == FRONT
empty: REAR == FRONT
B
full: (REAR+1)
mod n == FRONT
empty: (FRONT+1)
C
full: REAR == FRONT
empty: (REAR + 1)
mod n == FRONT
D
full: (FRONT+1)
mod n == REAR
empty: REAR == FRONT
3
GATE CSE 2012
MCQ (Single Correct Answer)
+1
-0.3
Which of the following statements are TRUE about an SQL query?

P: An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause
Q: An SQL query can contain a HAVING clause only if it has a GROUP BY clause
R: All attributes used in the GROUP BY clause must appear in the SELECT clause
S: Not all attributes used in the GROUP BY clause need to appear in the SELECT clause

A
P and R
B
P and S
C
Q and R
D
Q and S
4
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
Suppose R1 (A, B) and R2 (C, D) are two relation schemas. Let r1 and r2 be the corresponding relation instances. B is a foreign key that refers to C in R2. If data in r1 and r2 satisfy referential integrity constraints, which of the following is ALWAYS TRUE?
A
$$\prod_{B}(r_{1})- \prod _{C}(r_{2})= \varnothing$$
B
$$\prod_{C}(r_{2})- \prod _{B}(r_{1})= \varnothing$$
C
$$\prod_{B}(r_{1}) = \prod _{C}(r_{2})$$
D
$$\prod_{B}(r_{1}) - \prod _{C}(r_{2}) \neq \varnothing$$
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