GATE 2015 (Session 2) Computer Science and Information Technology (CS) Questions with Solutions

GATE 2015 (Session 2)

64 questions

MCQ 42 · NAT 221-mark 29 · 2-mark 35

Questions 51–55 of 64

Q52Conditional Statement2 marksNAT
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 __________.

Q53Pipeline Processor2 marksNAT
Consider the sequence of machine instructions given below:
MUL R5, R0, R1
DIV R6, R2, R3
ADD R7, R5, R6
SUB R8, R7, R4
In the above sequence, R0 to R8 are general purpose registers. In the instructions shown, the first register stores the result of the operation performed on the second and the third registers. This sequence of instructions is to be executed in a pipelined instruction processor with the following 4 stages: (1) Instruction Fetch and Decode (IF), (2) Operand Fetch (OF), (3) Perform Operation (PO) and (4) Write back the result (WB). The IF, OF and WB stages take 1 clock cycle each for any instruction. The PO stage takes 1 clock cycle for ADD or SUB instruction, 3 clock cycles for MUL instruction and 5 clock cycles for DIV instruction. The pipelined processor uses operand forwarding from the PO stage to the OF stage.

The number of clock cycles taken for the execution of the above sequence of instructions is ___________.

Q54Machine Instruction2 marksMCQ−0.67 if wrong
Consider a processor with byte-addressable memory. Assume that all registers, including Program Counter (PC) and Program Status Word (PSW), are of size 2 bytes. A stack in the main memory is implemented from memory location (0100)16(0100)_{16} and it grows upward. The stack pointer (SP) points to the top element of the stack. The current value of SP is (016E)16(016E)_{16}. The CALL instruction is of two words, the first word is the op-code and the second word is the starting address of the subroutine (one word = 2 bytes). The CALL instruction is implemented as follows:

Store the current value of PC in the stack
Store the value of PSW register in the stack
Load the starting address of the subroutine in PC

The content of PC just before the fetch of a CALL instruction is (5FA0)16(5FA0)_{16}. After execution of the CALL instruction, the value of the stack pointer is

Q55Boolean Algebra2 marksNAT
The number of min-terms after minimizing the following Boolean expression is _________.
[D′+AB′+A′C+AC′D+A′C′D]′{[{D}'+A{B}'+{A}'C+A{C}'D+{A}'{C}'{D}]}'

Q56Definite and Improper Integrals2 marksMCQ−0.67 if wrong
Let f(x)=x−(1/3)f(x)=x^{-(1/3)} and A denote the area of the region bounded by f(x) and the x-axis, when x varies from -1 to 1. Which of the following statements is/are TRUE?
I) f is continuous in [-1,1]
II) f is not bounded in [-1,1]
III) A is nonzero and finite