• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE-CS-2004

Question 41

What does the following algorithm approximate? C
    x = m;
    y = 1;
    while (x - y > e)
    {
        x = (x + y)/2;
        y = m/x;
    }
    print(x);
(Assume m > 1, e > 0).
  • log m
  • m2
  • m1/2
  • m1/3

Question 42

Consider the following C program segment c
struct CellNode
{
  struct CelINode *leftchild;
  int element;
  struct CelINode *rightChild;
}

int Dosomething(struct CelINode *ptr)
{
    int value = 0;
    if (ptr != NULL)
    {
      if (ptr->leftChild != NULL)
        value = 1 + DoSomething(ptr->leftChild);
      if (ptr->rightChild != NULL)
        value = max(value, 1 + DoSomething(ptr->rightChild));
    }
    return (value);
}
The value returned by the function DoSomething when a pointer to the root of a non-empty tree is passed as argument is
  • The number of leaf nodes in the tree
  • The number of nodes in the tree
  • The number of internal nodes in the tree
  • The height of the tree

Question 43

Suppose we run Dijkstra’s single source shortest-path algorithm on the following edge weighted directed graph with vertex P as the source. In what order do the nodes get included into the set of vertices for which the shortest path distances are finalized? gate2004
  • P, Q, R, S, T, U
  • P, Q, R, U, S, T
  • P, Q, R, U, T, S
  • P, Q, T, R, U, S

Question 44

Consider the grammar with the following translation rules and E as the start symbol.
E → E1 # T { E.value = E1.value * T.value }
         | T{ E.value = T.value }
T → T1 & F { T.value = T1.value + F.value }
          | F{ T.value = F.value }
F → num { F.value = num.value } 
Compute E.value for the root of the parse tree for the expression: 2 # 3 & 5 # 6 & 4.
  • 200
  • 180
  • 160
  • 40

Question 45

Consider the following set of processes, with the arrival times and the CPU-burst times given in milliseconds
  Process   Arrival Time    Burst Time
    P1          0              5
    P2          1              3
    P3          2              3
    P4          4              1
What is the average turnaround time for these processes with the preemptive shortest remaining processing time first (SRPT) algorithm ?
  • 5.50
  • 5.75
  • 6.00
  • 6.25

Question 46

Consider a system with a two-level paging scheme in which a regular memory access takes 150 nanoseconds, and servicing a page fault takes 8 milliseconds. An average instruction takes 100 nanoseconds of CPU time, and two memory accesses. The TLB hit ratio is 90%, and the page fault rate is one in every 10,000 instructions. What is the effective average instruction execution time?
  • 645 nanoseconds
  • 1050 nanoseconds
  • 1215 nanoseconds
  • 1230 nanoseconds

Question 47

Consider two processes P1 and P2 accessing the shared variables X and Y protected by two binary semaphores SX and SY respectively, both initialized to 1. P and V denote the usual semaphore operators, where P decrements the semaphore value, and V increments the semaphore value. The pseudo-code of P1 and P2 is as follows : P1 :

 While true do {
   L1 : ................
   L2 : ................
   X = X + 1;
   Y = Y - 1;
   V(SX);
   V(SY);             
 }

P2 :

 While true do {
   L3 : ................   
   L4 : ................
   Y = Y + 1;
   X = Y - 1;
   V(SY);
   V(SX);            
}

In order to avoid deadlock, the correct operators at L1, L2, L3 and L4 are respectively

  • P(SY), P(SX); P(SX), P(SY)

  • P(SX), P(SY); P(SY), P(SX)

  • P(SX), P(SX); P(SY), P(SY)

  • P(SX), P(SY); P(SX), P(SY)

Question 48

A Unix-style i-node has 10 direct pointers and one single, one double and one triple indirect pointers. Disk block size is 1 Kbyte, disk block address is 32 bits, and 48-bit integers are used. What is the maximum possible file size ?
  • 224 bytes
  • 232 bytes
  • 234 bytes
  • 248 bytes

Question 49

The relation scheme Student Performance (name, courseNo, rollNo, grade) has the following functional dependencies:
name, courseNo → grade
rollNo, courseNo → grade
name → rollNo
rollNo → name 
The highest normal form of this relation scheme is
  • 2 NF
  • 3 NF
  • BCNF
  • 4NF

Question 50

Consider the relation Student (name, sex, marks), where the primary key is shown underlined, pertaining to students in a class that has at least one boy and one girl. What does the following relational algebra expression produce? (Note: r is the rename operator). GATECS2004Q51 The condition in join is "(sex = female ^ x = male ^ marks ≤ m)"
  • names of girl students with the highest marks
  • names of girl students with more marks than some boy student
  • names of girl students with marks not less than some boy students4)
  • names of girl students with more marks than all the boy students

There are 90 questions to complete.

Last Updated :
Take a part in the ongoing discussion