GATE CS 1997

Last Updated :
Discuss
Comments

Question 1

A concurrent system consists of 3 processes using a shared resource R in a non-preemptible and mutually exclusive manner. The processes have unique priorities in the range 1.....3, 3 being the highest priority. It is required to synchronize the processes such that the resource is always allocated to the highest priority requester. The pseudo code for the system is as follows.
Shared Data
mutex:semaphore = 1:/* initialized to 1*/
process[3]:semaphore = 0; /*all initialized to 0 */
R_requested [3]:boolean = false; /*all initialized to false */
busy: boolean = false; /*initialized to false */
Code for processes
begin process
my-priority:integer;
my-priority:=____; /*in the range 1...3*/
repeat
    request_R(my-priority);
    P (proceed [my-priority]);
    {use shared resource R}
    release_R (my-priority);
forever
end process;
Procedures
procedure request_R(priority);
P(mutex);
if busy = true then
    R_requested [priority]:=true;
else
 begin
    V(proceed [priority]);
    busy:=true;
 end
V(mutex);
Give the pseudo code for the procedure release_R.

    Question 2

    A priority queue Q is used to implement a stack S that stores characters. PUSH(C) is implemented as INSERT(Q, C, K) where K is an appropriate integer key chosen by the implementation. POP is implemented as DELETEMIN(Q). For a sequence of operations, the keys chosen are in

    • Non-increasing order

    • Non-decreasing order

    • strictly increasing order

    • strictly decreasing order

    Question 3

    [5-Marks question] Consider a graph whose vertices are points in the plane with integer co-ordinates (x,y) such that 1≤x≤n and 1≤y≤n, where n≥2 is an integer. Two vertices (x1,y1) and (x2,y2) are adjacent iff ∣ x1−x2 ∣ ≤ 1 and ∣ y1–y2 ∣ ≤1. The weight of an edge {(x1,y1),(x2,y2)} is √(x1–x2)2+(y1–y2) a.  What is the weight of a minimum weight-spanning tree in this graph? Write only the answer without any explanations. b.  What is the weight of a maximum weight-spanning tree in this graph? Write only the answer without any explanations.

      Question 4

      The correct matching for the following pairs is
      (A) All pairs shortest path          (1) Greedy
      (B) Quick Sort                       (2) Depth-First search
      (C) Minimum weight spanning tree     (3) Dynamic Programming
      (D) Connected Components             (4) Divide and and Conquer
      
      Codes:
           A    B    C    D 
      a    2    4    1    3
      b    3    4    1    2
      c    3    4    2    1
      d    4    1    2    3
      
      • a
      • b
      • c
      • d

      Question 5

      An array A contains n≥1 positive integers in the locations A[1], A[2],... A[n]. The following program fragment prints the length of a shortest sequence of consecutive elements of A, A[i], A[i+1],...A[j] such that the sum of their values is ≥M, a given positive number. It prints ‘n+1’ if no such sequence exists. Complete the program by filling in the boxes. In each case use the simplest possible expression. Write only the line number and the contents of the box. ccc

        Question 6

        Locality of reference implies that the page reference being made by a process
        • will always be to the page used in the previous page reference
        • is likely to be to one of the pages used in the last few page references
        • will always be to one of the pages existing in memory
        • will always lead to a page fault

        Question 7

        Thrashing
        • reduces page I/O
        • decreases the degree of multiprogramming
        • implies excessive page I/O
        • improves the system performance

        Question 8

        Dirty bit for a page in a page table
        • helps avoid unnecessary writes on a paging device
        • helps maintain LRU information
        • allows only read on a page
        • none of the above

        Question 9

        [5-Marks question] Let L = {a1,  a2, .........., an} n ≥ 0 be a list whose Pascal representation is
        type list = record
        next:↑ list; val: integer   end
        The following function returns a list in which a2i and a2i-1, 1 ≤ i ≤ [n/2] are interchanged. Complete the function by filling the boxes. Write the line number and the content of the box in your answer sheet. aa                

          Question 10

          [5-Marks question] Consider the following program in Pseudo-Pascal syntax.
          program what:
              var z: integer
              procedure recur(x):
              begin if x <= 40 then
                  begin x:x+z
                      recur(x);
                      z:=x+10
                  end
              end(*recur*)
          begin(*what*)
              z=10;
              recur(z);
              writeln(z)
          end
          
          a. Suppose the parameter to the procedure ‘recur’ is passed by value. i. What value is printed by program? ii. How many times is ‘recur’ called? b. What value is printed by the program if the parameter is passed by reference?
            Tags:

            There are 75 questions to complete.

            Take a part in the ongoing discussion