Programming and Data Structures questions — page 7 of 9

Q27

GATE CS 2015 CS-3Tree Data StructuresMCQ1 mark−1/3 if wrong
While inserting the elements 71,65,84,69,67,8371, 65, 84, 69, 67, 83 in an empty binary search tree (BST) in the sequence shown, the element in the lowest level is
Show answer without attempting

Answer: B

Q28

GATE CS 2015 CS-3Linear Data StructuresMCQ1 mark−1/3 if wrong
The result evaluating the postfix expression 10  5  +  60  6  /  ∗  8  −10 \; 5 \; + \; 60 \; 6 \; / \; * \; 8 \; - is
Show answer without attempting

Answer: C

Q30

GATE CS 2015 CS-3Tree Data StructuresMCQ1 mark−1/3 if wrong
Consider the following array of elements.

(89,19,50,17,12,15,2,5,7,11,6,9,100)(89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100)

The minimum number of interchanges needed to convert it into a max-heap is
Show answer without attempting

Answer: D

Q33

GATE CS 2015 CS-3Linear Data StructuresNAT1 mark
Consider a software program that is artificially seeded with 100 faults. While testing this program, 159 faults are detected, out of which 75 faults are from those artificially seeded faults. Assuming that both real and seeded faults are of same nature and have same distribution, the estimated number of undetected real faults is ____________.
Show answer without attempting

Answer: 28

Q38

GATE CS 2015 CS-3RecursionMCQ2 marks−2/3 if wrong
Consider the following recursive C function.
void get(int n)
{
    if (n<1) return;
    get(n-1);
    get(n-3);
    printf("%d", n);
}
If get(6) function is being called in main() then how many times will the get() function be invoked before returning to the main()?
Show answer without attempting

Answer: B

Q42

GATE CS 2015 CS-3C ProgrammingNAT2 marks
Consider the following C program.
#include <stdio.h>
int f1(void);
int f2(void);
int f3(void);
int x = 10;

int main ( )
{
    int x = 1;
    x += f1() + f2() + f3() + f2();
    printf("%d", x);
    return 0;
}

int f1() { int x = 25; x++; return x;}
int f2() { static int x = 50; x++; return x;}
int f3() { x *= 10; return x;}
The output of the program is ____________.
Show answer without attempting

Answer: 230

Q43

GATE CS 2015 CS-3C ProgrammingNAT2 marks
Consider the following C program.
#include<stdio.h>
int main( )
{
    static int a[ ] = {10, 20, 30, 40, 50};
    static int *p[ ] = {a, a+3, a+4, a+1, a+2};
    int **ptr = p;
    ptr++;
    printf("%d%d", ptr-p, **ptr);
}
The output of the program is ____________.
Show answer without attempting

Answer: 140

Q53

GATE CS 2015 CS-3C ProgrammingNAT2 marks
Consider the following C program:
#include<stdio.h>
int main( )
{
    int i, j, k = 0;
    j = 2 * 3 / 4 + 2.0 / 5 + 8 / 5;
    k -= --j;
    for(i = 0; i < 5; i++)
    {
        switch(i + k)
        {
            case 1:
            case 2: printf("\n%d", i+k);
            case 3: printf("\n%d", i+k);
            default: printf("\n%d", i+k);
        }
    }
    return 0;
}
The number of times printf statement is executed is ____________.
Show answer without attempting

Answer: 10

Q63

GATE CS 2015 CS-3Linear Data StructuresNAT2 marks
Suppose c=⟨c[0],…,c[k−1]⟩c = \langle c[0], \dots, c[k-1] \rangle is an array of length kk, where all the entries are from the set {0,1}\{0, 1\}. For any positive integers aa and nn, consider the following pseudocode.
DOSOMETHING(c, a, n)
z ← 1
for i ← 0 to k − 1
    do z ← z² mod n
       if c[i] = 1
          then z ← (z × a) mod n
return z
If k=4k = 4, c=⟨1,0,1,1⟩c = \langle 1, 0, 1, 1 \rangle, a=2a = 2 and n=8n = 8, then the output of DOSOMETHING(c,a,nc, a, n) is ____________.
Show answer without attempting

Answer: 0

Q15

GATE CS 2015 CS-1Tree Data StructuresMCQ1 mark−1/3 if wrong
The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum number of nodes in a binary tree of height 5 are
Show answer without attempting

Answer: A

Q16

GATE CS 2015 CS-1C ProgrammingMCQ1 mark−1/3 if wrong
Match the following:

(P) Condition coverage
(Q) Equivalence class partitioning
(R) Volume testing
(S) Alpha testing

(i) Black-box testing
(ii) System testing
(iii) White-box testing
(iv) Performance testing
Show answer without attempting

Answer: C

Q17

GATE CS 2015 CS-1Tree Data StructuresMCQ1 mark−1/3 if wrong
Which of the following is/are correct inorder traversal sequence(s) of binary search tree(s)?

I. 3, 5, 7, 8, 15, 19, 25
II. 5, 8, 9, 12, 10, 15, 25
III. 2, 7, 10, 8, 14, 16, 20
IV. 4, 6, 7, 9, 18, 20, 25
Show answer without attempting

Answer: A

Q34

GATE CS 2015 CS-1C ProgrammingNAT1 mark
The output of the following C program is ________.
void f1(int a, int b) {
    int c;
    c = a; a = b; b = c;
}
void f2(int *a, int *b) {
    int c;
    c = *a; *a = *b; *b = c;
}
int main() {
    int a = 4, b = 5, c = 6;
    f1(a, b);
    f2(&b, &c);
    printf("%d", c - a - b);
}
Show answer without attempting

Answer: -5

Q35

GATE CS 2015 CS-1Tree Data StructuresMCQ1 mark−1/3 if wrong
What are the worst-case complexities of insertion and deletion of a key in a binary search tree?
Show answer without attempting

Answer: B

Q37

GATE CS 2015 CS-1Tree Data StructuresMCQ2 marks−2/3 if wrong
Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4.
Array Index123456789
Value4030201015161784
Now consider that a value 35 is inserted into this heap. After insertion, the new heap is
Show answer without attempting

Answer: B

Q62

GATE CS 2015 CS-1C ProgrammingMCQ2 marks−2/3 if wrong
What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory.
int main() {
    unsigned int x[4][3] =
        {{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
    printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3);
}
Show answer without attempting

Answer: A

Q65

GATE CS 2015 CS-1C ProgrammingMCQ2 marks−2/3 if wrong
Consider the following pseudo code, where xx and yy are positive integers.
begin
  q := 0
  r := x
  while r >= y do
    begin
      r := r - y
      q := q + 1
    end
end
The post condition that needs to be satisfied after the program terminates is
Show answer without attempting

Answer: B

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

0/200 correct0 marks

Related topics in GATE CS