Programming and Data Structures questions — page 8 of 9

Q24

GATE CS 2015 CS-2RecursionNAT1 mark
Consider the following C function.
int fun(int n){
    int x=1, k;
    if (n==1) return x;
    for (k=1; k<n; ++k)
        x = x + fun(k) * fun(n-k);
    return x;
}
The return value of fun(5) is _________.
Show answer without attempting

Answer: 51

Q25

GATE CS 2015 CS-2C ProgrammingMCQ1 mark−1/3 if wrong
A software requirements specification (SRS) document should avoid discussing which one of the following?
Show answer without attempting

Answer: C

Q29

GATE CS 2015 CS-2C ProgrammingMCQ1 mark−1/3 if wrong
Consider the basic COCOMO model where EE is the effort applied in person-months, DD is the development time in chronological months, KLOCKLOC is the estimated number of delivered lines of code (in thousands) and ab,bb,cb,dba_b, b_b, c_b, d_b have their usual meanings. The basic COCOMO equations are of the form
Show answer without attempting

Answer: A

Q48

GATE CS 2015 CS-2Linear Data StructuresNAT2 marks
A Young tableau is a 2D array of integers increasing from left to right and from top to bottom. Any unfilled entries are marked with ∞\infty, and hence there cannot be any entry to the right of, or below a ∞\infty. The following Young tableau consists of unique entries.

When an element is removed from a Young tableau, other elements should be moved into its place so that the resulting table is still a Young tableau (unfilled entries may be filled in with a ∞\infty). The minimum number of entries (other than 1) to be shifted, to remove 1 from the given Young tableau is _______________.
Question figure
Show answer without attempting

Answer: 5

Q52

GATE CS 2015 CS-2Linear Data StructuresNAT2 marks
Consider the C program below.
#include <stdio.h>
int *A, stkTop;

int stkFunc(int opcode, int val)
{
    static int size=0, stkTop=0;

    switch (opcode) {
        case -1: size = val; break;
        case  0: if (stkTop < size) A[stkTop++] = val; break;
        default: if (stkTop) return A[--stkTop];
    }
    return -1;
}

int main()
{
    int B[20]; A = B; stkTop = -1;

    stkFunc (-1, 10);
    stkFunc ( 0, 5);
    stkFunc ( 0, 10);
    printf ("%d\n", stkFunc(1, 0) + stkFunc(1, 0));
}
The value printed by the above program is ___________.
Show answer without attempting

Answer: 15

Q64

GATE CS 2015 CS-2C ProgrammingMCQ2 marks−2/3 if wrong
Which one of the following assertions concerning code inspection and code walkthrough is true?
Show answer without attempting

Answer: C

Q10

GATE CS 2014 CS-2C ProgrammingNAT1 mark
Consider the function func shown below:
int func(int num) {
int count = 0;
    while (num) {
       count++;
       num>>= 1;
    }
return (count);
}
The value returned by func(435) is __________.
Show answer without attempting

Answer: 9

Q11

GATE CS 2014 CS-2C ProgrammingMCQ1 mark−1/3 if wrong
Suppose n and p are unsigned int variables in a C program. We wish to set p to nC3^{n}C_{3}. If n is large, which one of the following statements is most likely to set p correctly?
Show answer without attempting

Answer: B

Q12

GATE CS 2014 CS-2Tree Data StructuresMCQ1 mark−1/3 if wrong
A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is: 10, 8, 5, 3, 2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is:
Show answer without attempting

Answer: A

Q39

GATE CS 2014 CS-2Tree Data StructuresNAT2 marks
Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the values at the leaves, the maximum possible value of the expression represented by the tree is ___.
Question figure
Show answer without attempting

Answer: 6

Q40

GATE CS 2014 CS-2RecursionNAT2 marks
Consider the following function
double f(double x){
   if( abs(x*x - 3) < 0.01) return x;
   else return f(x/2 + 1.5/x);
}
Give a value q (to 2 decimals) such that f(q) will return q:_____.
Show answer without attempting

Answer: 1.72 to 1.74

Q41

GATE CS 2014 CS-2Linear Data StructuresMCQ2 marks−2/3 if wrong
Suppose a stack implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack?
Show answer without attempting

Answer: C

Q42

GATE CS 2014 CS-2RecursionMCQ2 marks−2/3 if wrong
Consider the C function given below.
int f(int j)
{
  static int i = 50;
  int k;
  if (i == j)
     {
       printf("something");
       k = f(i);
       return 0;
     }
  else return 0;
}
Which one of the following is TRUE?
Show answer without attempting

Answer: D

Q10

GATE CS 2014 CS-3Linear Data StructuresMCQ1 mark−1/3 if wrong
Let AA be a square matrix of size n×nn \times n. Consider the following pseudocode. What is the expected output?
C = 100;
for i = 1 to n do
  for j = 1 to n do
  {
    Temp = A[i][j] + C;
    A[i][j] = A[j][i];
    A[j][i] = Temp - C;
  }
for i = 1 to n do
  for j = 1 to n do
    output (A[i][j]);
Show answer without attempting

Answer: A

Q12

GATE CS 2014 CS-3Tree Data StructuresMCQ1 mark−1/3 if wrong
Consider the following rooted tree with the vertex labeled P as the root:

The order in which the nodes are visited during an in-order traversal of the tree is
Question figure
Show answer without attempting

Answer: A

Q39

GATE CS 2014 CS-3Tree Data StructuresNAT2 marks
Suppose we have a balanced binary search tree TT holding nn numbers. We are given two numbers LL and HH and wish to sum up all the numbers in TT that lie between LL and HH. Suppose there are mm such numbers in TT. If the tightest upper bound on the time to compute the sum is O(nalog⁡bn+mclog⁡dn)O(n^a \log^b n + m^c \log^d n), the value of a+10b+100c+1000da + 10b + 100c + 1000d is ____.
Show answer without attempting

Answer: 110

Q41

GATE CS 2014 CS-3Tree Data StructuresMCQ2 marks−2/3 if wrong
Consider the pseudocode given below. The function DoSomething() takes as argument a pointer to the root of an arbitrary tree represented by the leftMostChild-rightSibling representation. Each node of the tree is of type treeNode.
typedef struct treeNode* treeptr;
struct treeNode
{
  treeptr leftMostChild, rightSibling;
};
int DoSomething (treeptr tree)
{
  int value=0;
  if (tree != NULL) {
    if (tree->leftMostChild == NULL)
      value = 1;
    else
      value = DoSomething(tree->leftMostChild);
    value = value + DoSomething(tree->rightSibling);
  }
  return(value);
}
When the pointer to the root of a tree is passed as the argument to DoSomething, the value returned by the function corresponds to the
Show answer without attempting

Answer: D

Q42

GATE CS 2014 CS-3Linear Data StructuresMCQ2 marks−2/3 if wrong
Consider the C function given below. Assume that the array listA contains n (> 0) elements, sorted in ascending order.
int ProcessArray(int *listA, int x, int n)
{
  int i, j, k;
  i = 0;
  j = n-1;
  do {
    k = (i+j)/2;
    if (x <= listA[k])
      j = k-1;
    if (listA[k] <= x)
      i = k+1;
  }while (i <= j);
  if (listA[k] == x)
    return(k);
  else
    return -1;
}
Which one of the following statements about the function ProcessArray is CORRECT?
Show answer without attempting

Answer: B

Q10

GATE CS 2014 CS-1C ProgrammingMCQ1 mark−1/3 if wrong
Consider the following program in C language:
#include <stdio.h>
main()
{
 int i;
 int *pi = &i;
 scanf("%d",pi);
 printf("%d\n", i+5);
}
Which one of the following statements is TRUE?
Show answer without attempting

Answer: D

Q12

GATE CS 2014 CS-1Tree Data StructuresNAT1 mark
Consider a rooted nn node binary tree represented using pointers. The best upper bound on the time required to determine the number of subtrees having exactly 4 nodes is O(nalog⁡bn)O(n^a \log^b n). Then the value of a+10ba + 10b is ___________.
Show answer without attempting

Answer: 1

0/200 correct0 marks

Related topics in GATE CS