GATE 2014 (Session 3) Computer Science and Information Technology (CS) Questions with Solutions

GATE 2014 (Session 3)

65 questions

MCQ 47 · NAT 181-mark 30 · 2-mark 35

Questions 51–55 of 65

Q51Binary Tree2 marksMCQ−0.67 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

Q52Array and Pointer2 marksMCQ−0.67 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?

Q53Pipeline Processor2 marksNAT
An instruction pipeline has five stages, namely, instruction fetch (IF), instruction decode and register fetch (ID/RF), instruction execution (Ex), memory access (MEM), and register write back (WB) with stage latencies 1 ns, 2.2 ns, 2 ns, 1 ns, and 0.75 ns, respectively (ns stands for nanoseconds). To gain in terms of frequency, the designers have decided to split the ID/RF stage into three stages (ID, RF1, RF2) each of latency 2.2/3 ns. Also, the Ex stage is split into two stages (Ex1, Ex2) each of latency 1 ns. The new design has a total of eight pipeline stages. A program has 20% branch instructions which execute in the Ex stage and produce the next instruction pointer at the end of the Ex stage in the old design and at the end of the Ex2 stage in the new design. The IF stage stalls after fetching a branch instruction until the next instruction pointer is computed. All instructions other than the branch instruction have an average CPI of one in both the designs. The execution times of this program on the old and the new design are P and Q nanoseconds, respectively. The value of P/Q is __________

Q54Cache Memory2 marksNAT
The memory access time is 1 nanosecond for a read operation with a hit in cache, 5 nanoseconds for a read operation with a miss in cache, 2 nanoseconds for a write operation with a hit in cache and 10 nanoseconds for a write operation with a miss in cache. Execution of a sequence of instructions involves 100 instruction fetch operations, 60 memory operand read operations and 40 memory operand write operations. The cache hit-ratio is 0.9. The average memory access time (in nanoseconds) in executing the sequence of instructions is __________.

Q55Sequential Circuit2 marksMCQ−0.67 if wrong
C C C J K J K J K Q2 Q1 Q0 Q2 Q1 Q0
The above synchronous sequential circuit built using JK flip-flops is initialized with Q2Q1Q0Q_{2}Q_{1}Q_{0} = 000. The state sequence for this circuit for the next 3 clock cycles is