Programming and Data Structures questions — page 2 of 2

Q21

GATE CS 2015 CS-2C ProgrammingMCQ1 mark−1/3 if wrong
Consider the following function written in the C programming language.
void foo(char *a){
    if ( *a && *a != ' '){
        foo(a+1);
        putchar(*a);
    }
}
The output of the above function on input "ABCD EFGH" is
Show answer without attempting

Answer: D

Q22

GATE CS 2015 CS-2Tree Data StructuresMCQ1 mark−1/3 if wrong
Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The lower bound for the number of operations to convert the tree to a heap is
Show answer without attempting

Answer: A

Q23

GATE CS 2015 CS-2Tree Data StructuresNAT1 mark
A binary tree T has 20 leaves. The number of nodes in T having two children is _______.
Show answer without attempting

Answer: 19

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

0/90 correct0 marks

Related topics in GATE CS