GATE 2001 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2001

60 questions

MCQ 601-mark 60

Questions 31–35 of 60

Q31Function1 markMCQ−0.33 if wrong
What is printed by the print statements in the program P1 assuming call by reference parameter passing ?
 Program P1()
{
   x = 10;
   y = 3;
   func1(y,x,x);
   print x;
   print y;
}
func1(x,y,z)
{
   y = y+4;
   z = x+y+z;
}

Q32Array and Pointer1 markMCQ−0.33 if wrong
Consider the following three functions :
[P1]
  int * g (void) 
{ 
  int x= 10; 
  return (&x); 
}
[P2]
   int * g (void) 
{ 
  int * px; 
  *px= 10; 
  return px; 
} 
[P3]
  int *g (void) 
{ 
  int *px; 
  px = (int *) malloc (sizeof(int)); 
  *px= 10; 
  return px; 
} 
Which of the above three functions are likely to cause problems with pointers ?

Q33Queue1 markMCQ−0.33 if wrong
What is the minimum number of stacks of size n required to implement a queue to size n ?

Q34Heap Tree1 markMCQ−0.33 if wrong
Consider any array representation of an n element binary heap where the elements are stored from index 1 to index n of the array. For the element stored at index i of the array (i≤ni\leq n ) , the index of the parent is

Q35Sorting1 markMCQ−0.33 if wrong
Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort ?