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

GATE 2010

82 questions

MCQ 821-mark 39 · 2-mark 43

Questions 26–30 of 82

Q26Pipeline Processor2 marksMCQ−0.67 if wrong
A 5-stage pipelined processor has Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Perform Operation (PO) and Write Operand (WO) stages. The IF, ID, OF and WO stages take 1 clock cycle each for any instruction. The PO stage takes 1 clock cycle for ADD and SUB instructions, 3 clock cycles for MUL instruction, and 6 clock cycles for DIV instruction respectively. Operand forwarding is used in the pipeline. What is the number of clock cycles needed to execute the following sequence of instructions?
Instruction Meaning of instruction I0 : MUL R2,R0,R1 R2 ← R0 * R1 I1 : DIV R5,R3,R4 R5 ← R3 / R4 I2 : ADD R2,R5,R2 R2 ← R5 + R2 I3 : SUB R5,R2,R6 R5 ← R2 − R6

Q27Function2 marksMCQ−0.67 if wrong
What is the value printed by the following C program?
 #include <stdio.h>
int f(int * a, int n)
{
    if(n<=0)return 0;
    else if(*a% 2 ==0) return *a+f(a+1,n-1);
    else return *a-f(a+1,n-1);
}
int main ( )
{
    int a[ ] = {12, 7, 13, 4, 11, 6};
    printf ("%d", f(a,6));
    return 0;
} 

Q28Array and Pointer1 markMCQ−0.33 if wrong
What does the following program print?
 #include <stdio.h>
void f (int *p, int * q) {
       p=q;
       *p=2;
}
int i= 0, j= 1;
int main ( ){
     f(&i, & j);
     printf( "%d%d \n", i,j);
     return 0;
} 

Q30Binary Tree1 markMCQ−0.33 if wrong
In a binary tree with n nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child?