GATE 1999 Computer Science questions and solutions

# Recent questions tagged gate1999 1
Consider the following solution to the producer-consumer problem using a buffer of size 1. Assume that the initial value of count is 0. Also assume that the testing of count and assignment to count are atomic operations. Producer: Repeat Produce an item; if count = ... Producer); Consume item; Forever; Show that in this solution it is possible that both the processes are sleeping at the same time.
1 vote
2
Consider the set of relations EMP (Employee-no. Dept-no, Employee-name, Salary) DEPT (Dept-no. Dept-name, Location) Write an SQL query to: Calculate, for each department number, the number of employees with a salary greater than Rs. 1,00,000
3
Write a constant time algorithm to insert a node with data $D$ just before the node with address $p$ of a singly linked list.
4
Mr. X claims the following: If a relation R is both symmetric and transitive, then R is reflexive. For this, Mr. X offers the following proof: &ldquo;From xRy, using symmetry we get yRx. Now because R is transitive xRy and yRx together imply xRx. Therefore, R is reflexive&rdquo;. Give an example of a relation R which is symmetric and transitive but not reflexive.
5
Consider the set of relations EMP (Employee-no. Dept-no, Employee-name, Salary) DEPT (Dept-no. Dept-name, Location) Write an SQL query to: a)Find all employees names who work in departments located at ‘Calcutta’ and whose salary is greater than Rs.50,000. b)Calculate, for each department number, the number of employees with a salary greater than Rs. 1,00,000.
6
Consider a B-tree with degree $m$, that is, the number of children, $c$, of any internal node (except the root) is such that $m \leq c \leq 2m-1$. Derive the maximum and minimum number of records in the leaf nodes for such a B-tree with height $h, h \geq 1$. (Assume that the root of a tree is at height 0).
7
A certain processor provides a 'test and set' instruction that is used as follows: TSET register, flag This instruction atomically copies flag to register and sets flag to $1$. Give pseudo-code for implementing the entry and exit code to a critical region using this instruction.
8
A certain computer system has the segmented paging architecture for virtual memory. The memory is byte addressable. Both virtual and physical address spaces contain $2^{16}$ bytes each. The virtual address space is divided into $8$ non-overlapping equal size segments. The ... are available in page table entry for storing the aging information for the page? Assume that the page size is $512$ bytes.
9
Design a 2K $\times$ 8 (2048 locations, each 8 bit wide) memory system mapped at addresses (1000)$_{16}$ to (17FF)$_{16}$ for the 8085 processor using four 1K $\times$ 4 memory chips. Each of these chips has the following signal pins: $\overline{CS}$ (Chip ... $A_0$ is the lest significant) $D_0, D_1, D_2, D_3$ (bi-directional data lines. $D_0$ is the least significant)
10
Consider the following program fragment in the assembly language of a certain hypothetical processor. The processor has three general purpose registers $R1, R2$and $R3$. The meanings of the instructions are shown by comments (starting with ;) after the instructions. X: CMP R1, 0; ... $R3$ when control reaches $Z$?
11
12
What will be the output of the following program assuming that parameter passing is call by value call by reference call by copy restore procedure P{x, y, z}; begin y:y+1; z: x+x end; begin a:= b:= 3; P(a+b, a, a); Print(a) end.
13
Show that the formula $\left[(\sim p \vee q) \Rightarrow (q \Rightarrow p)\right]$ is not a tautology. Let $A$ be a tautology and $B$ any other formula. Prove that $(A \vee B)$ is a tautology.
14
An instruction pipeline consists of $4$ stages - Fetch $(F)$, Decode field $(D)$, Execute $(E)$ and Result Write $(W)$. The $5$ instructions in a certain instruction sequence need these stages for the different number of clock cycles as shown by the table below \begin{array}{ ... & \text{$1$} & \text{$2$} \\\hline \end{array} Find the number of clock cycles needed to perform the $5$ instructions.
15
In binary tree, a full node is defined to be a node with $2$ children. Use induction on the height of the binary tree to prove that the number of full nodes plus one is equal to the number of leaves. Draw the min-heap that results from insertion of the following elements in order into an initially empty min-heap: $7, 6, 5, 4, 3, 2, 1$. Show the result after the deletion of the root of this heap.
16
Consider the following algorithms. Assume, procedure $A$ and procedure $B$ take $O (1)$ and $O(1/n)$ unit of time respectively. Derive the time complexity of the algorithm in $O$-notation. algorithm what (n) begin if n = 1 then call A else begin what (n-1); call B(n) end end.
17
Suppose we have a function HALTS which when applied to any arbitrary function $f$ and its arguments will say TRUE if function $f$ terminates for those arguments and FALSE otherwise. Example: Given the following function definition. FACTORIAL (N) = IF (N=0) ... not possible to have a function like HALTS which for arbitrary functions and inputs says whether it will terminate on that input or not.
18
Let synthesized attribute val give the value of the binary number generated by S in the following grammar. For example, on input 101.101, S.val = 5.625. $S \rightarrow L.L \mid L$ $L \rightarrow LB \mid B$ $B \rightarrow 0 \mid 1$ Write S-attributed values corresponding to each of the productions to find S.val.
19
Let $A$ be an $n \times n$ matrix such that the elements in each row and each column are arranged in ascending order. Draw a decision tree, which finds $1$st, $2$nd and $3$rd smallest elements in minimum number of comparisons.
20
Show that the language $L = \left\{ xcx \mid x \in \left\{0,1\right\}^* \text{ and }c\text{ is a terminal symbol}\right\}$ is not context free. $c$ is not $0$ or $1$.
21
Given that $A$ is regular and $(A \cup B)$ is regular, does it follow that $B$ is necessarily regular? Justify your answer. Given two finite automata $M1, M2$, outline an algorithm to decide if $L(M1) \subset L(M2)$. (note: strict subset)
22
Let $G$ be a connected, undirected graph. A cut in $G$ is a set of edges whose removal results in $G$ being broken into two or more components, which are not connected with each other. The size of a cut is called its cardinality. A min-cut of $G$ is a cut in $G$ of minimum ... $G$ with $n$ vertices has a min-cut of cardinality $k$, then $G$ has at least $\left(\frac{n\times k}{2}\right)$ edges.
23
Let $G$ be a finite group and $H$ be a subgroup of $G$. For $a \in G$, define $aH=\left\{ah \mid h \in H\right\}$. Show that $|aH| = |bH|.$ Show that for every pair of elements $a, b \in G$, either $aH = bH$ or $aH$ and $bH$ are disjoint. Use the above to argue that the order of $H$ must divide the order of $G.$
24
Which of the following is/are correct? An SQL query automatically eliminates duplicates An SQL query will not work if there are no indexes on the relations SQL permits attribute names to be repeated in the same relation None of the above
25
Consider the following $C$ function definition int Trial (int a, int b, int c) { if ((a>=b) && (c<b)) return b; else if (a>=b) return Trial(a, c, b); else return Trial(b, a, c); } The functional Trial: Finds the maximum of $a$, $b$, and $c$ Finds the minimum of $a$, $b$, and $c$ Finds the middle number of $a$, $b$, $c$ None of the above
26
A certain processor supports only the immediate and the direct addressing modes. Which of the following programming language features cannot be implemented on this processor? Pointers Arrays Records Recursive procedures with local variable
27
The main difference(s) between a CISC and a RISC processor is/are that a RISC processor typically has fewer instructions has fewer addressing modes has more registers is easier to implement using hard-wired logic
If $T_1 = O(1)$, give the correct matching for the following pairs: $\begin{array}{l|l}\hline \text{(M)$T_n = T_{n-1} + n$} & \text{(U)$T_n = O(n)$} \\\hline \text{(N)$T_n = T_{n/2} + n$} & \text{(V)$T_n = O(n \log n)$} \\\hline \text{(O)$T_n = T_{n/2} + n \log n$} & \text{(W)$T_n ... $\text{M-W, N-U, O-X, P-V}$ $\text{M-V, N-W, O-X, P-U}$ $\text{M-W, N-U, O-V, P-X}$