Question 1
The goal of structured programming is to
 A have well indented programs B be able to infer the flow of control from the compiled code C be able to infer the flow of control from the program text D avoid the use of GOTO statements
Principles of Programming Languages    GATE-CS-2004
Discuss it

Question 1 Explanation:
The main goal of structured programming is to get an understanding about the flow of control in the given program text. In structure programming various control structures such as switch-case, if-then-else, while, etc. allows a programmer to decode the flow of the program easily.
 Question 2
Consider the following C function
void swap (int a, int b)
{
int temp;
temp = a;
a = b;
b = temp;
}

In order to exchange the values of two variables x and y.
 A Call swap (x, y) B Call swap (&x, &y) C swap(x,y) cannot be used as it does not return any value D swap(x,y) cannot be used as the parameters are passed by value
Functions    GATE-CS-2004
Discuss it

Question 2 Explanation:
 Question 3
A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top2 (topl< top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for “stack full” is
 A (top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1) B top1 + top2 = MAXSIZE C (top1= MAXSIZE/2) or (top2 = MAXSIZE) D top1= top2 -1
GATE-CS-2004
Discuss it

Question 3 Explanation:
 Question 4
The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)?
 A 2 B 3 C 4 D 6
GATE-CS-2004
Discuss it

Question 4 Explanation:
 Question 5
The best data structure to check whether an arithmetic expression has balanced parentheses is a
 A queue B stack C tree D list
GATE-CS-2004
Discuss it

Question 5 Explanation:
 Question 6
Level order traversal of a rooted tree can be done by starting from the root and performing
 A preorder traversal B inorder traversal C depth first search D breadth first search
Tree Traversals    GATE-CS-2004
Discuss it

Question 6 Explanation:
See this post for details
 Question 7
Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function x mod 10, which of the following statements are true?

1.    9679, 1989, 4199 hash to the same value
2.    1471, 6171 hash to the same value
3.    All elements hash to the same value
4.    Each element hashes to a different value 
 A 1 only B 2 only C 1 and 2 only D 3 or 4
GATE-CS-2004
Discuss it

Question 7 Explanation:
The hash value for 9679, 1989, 4199 is 9 and hash value for 1471, 6171 is 1.
 Question 8
Which of the following grammar rules violate the requirements of an operator grammar ? P, Q, R are nonterminals, and r, s, t are terminals.
1.    P → Q R
2.    P → Q s R
3.    P → ε
4.    P → Q t R r 
 A 1 only B 1 and 3 only C 2 and 3 only D 3 and 4 only
Parsing and Syntax directed translation    GATE-CS-2004
Discuss it

Question 8 Explanation:
 Question 9
Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2, the reference will be resolved at
Misc    GATE-CS-2004
Discuss it

Question 9 Explanation:
Note: Static linking is done at link-time, dynamic linking or shared libraries are brought in only at runtime. (A) Edit-time : Function references can never be given/determined at edit-time or code-writing time. Function references are different from function names. Function names are used at edit-time and function references are determined at linker-time for static libraries or at runtime for dynamic libraries. (B) Compile-time : Compile time binding is done for functions present in the same file or module. (C) Link-time : Link time binding is done in the linker stage, where functions present in separate files or modules are referenced in the executable. (D) Load-time : Function referencing is not done at load-time. Hence, correct answer would be (C).   This solution is contributed by Vineet Purswani.
 Question 10
Consider the grammar rule E → E1 - E2 for arith­metic expressions. The code generated is targeted to a CPU having a single user register. The sub­traction operation requires the first operand to be in the register. If E1 and E2 do not have any com­mon sub expression, in order to get the shortest possible code
 A E1 should be evaluated first B E2 should be evaluated first C Evaluation of E1 and E2 should necessarily be interleaved D Order of evaluation of E1 and E2 is of no consequence
Code Generation and Optimization    GATE-CS-2004
Discuss it

Question 10 Explanation:
E -> E1 - E2 Given that E1 and E2 don't share any sub expression, most optimized usage of single user register for evaluation of this production rule would come only when E2 is evaluated before E1. This is because when we will have E1  evaluated in the register, E2 would have been already computed and stored at some memory location. Hence we could just use subtraction operation to take the user register as first operand, i.e. E1 and E2 value from its   memory location referenced using some index register or some other form according to the instruction. Hence correct answer should be (B) E2 should be evaluated first.   This Solution is contributed by Vineet Purswani.
 Question 11
Consider the following statements with respect to user-level threads and kernel supported threads

i.   context switch is faster with kernel-supported threads
ii.  for user-level threads, a system call can block the
entire process
iii. Kernel supported threads can be scheduled independently
iv.  User level threads are transparent to the kernel
Which of the above statements are true?
 A (ii), (iii) and (iv) only B (ii) and (iii) only C (i) and (iii) only D (i) and (ii) only
GATE-CS-2004
Discuss it

Question 11 Explanation:
User thread are implemented by users. kernel threads are implemented by OS.
OS doesn’t recognized user level threads. Kernel threads are recognized by OS.
Implementation of User threads is easy. Implementation of Kernel thread is complicated.
Context switch time is less. Context switch time is more.
Context switch requires no hardware support. Hardware support is needed.
If one user level thread perform blocking operation then entire process will be blocked. If one kernel thread perform blocking operation then another thread can continue execution.
 Question 12
Consider an operating system capable of loading and executing a single sequential user process at a time. The disk head scheduling algorithm used is First Come First Served (FCFS). If FCFS is replaced by Shortest Seek Time First (SSTF), claimed by the vendor to give 50% better benchmark results, what is the expected improvement in the I/O performance of user programs?
 A 50% B 40% C 25% D 0%
Input Output Systems    GATE-CS-2004
Discuss it

Question 12 Explanation:
Since Operating System can execute a single sequential user process at a time, the disk is accessed in FCFS manner always. The OS never has a choice to pick an IO from multiple IOs as there is always one IO at a time
 Question 13
Let R1 (A, B, C) and R2 (D, E) be two relation schema, where the primary keys are shown underlined, and let C be a foreign key in R1 referring to R2. Suppose there is no violation of the above referential integrity constraint in the corresponding relation instances r1 and r2. Which one of the following relational algebra expressions would necessarily produce an empty relation ?
 A 1 B 2 C 3 D 4
Database Design(Normal Forms)    GATE-CS-2004
Discuss it

Question 13 Explanation:
Since C is a foreign key in R1 and there is no violation of the above referential integrity constraint, the set of values in C must be a subset of values in R2.
 Question 14
Consider the following relation schema pertaining to a students database:
Student (rollno, name, address)
Enroll (rollno, courseno, coursename)
where the primary keys are shown underlined. The number of tuples in the Student and Enroll tables are 120 and 8 respectively. What are the maximum and minimum number of tuples that can be present in (Student * Enroll), where '*' denotes natural join ?
 A 8, 0 B 120, 8 C 960, 8 D 960, 120
SQL    GATE-CS-2004
Discuss it

Question 14 Explanation:
The result of the natural join is the set of all combinations of tuples in R and S that are equal on their common attribute names. What is the maximum possible number of tuples? The result of natural join becomes equal to the Cartesian product when there are no common attributes. The given tables have a common attribute, so the result of natural join cannot have more than the number of tuples in larger table.
        Student
-------------------------------------
-------------------------------------
1                a             abc
2                b             bcd
3                c             cde

Enroll
----------------------------------------------
Rollno           Courseno          Coursename
----------------------------------------------
1                 12                 pqr
1                 14                 qrs
1                 15                 rst
2                 13                 uvw
2                 14                 qrs

Result of natural join
----------------------------------------------
----------------------------------------------
1        a      abc         12      pqr
1        a      abc         14      qrs
1        a      abc         15      rst
2        b      bcd         13      uvw
2        b      bcd         14      qrs 
What is the maximum possible number of tuples? It might be possible that there is no rollnumber common. In that case, the number of tupples would be 0.
 Question 15
Choose the best matching between Group 1 and Group 2.
   Group-1   	  	  Group-2
P. Data link          1. Ensures reliable transport of data
Q. Network layer      2. Encoder/decodes data for physical
transmission
R. Transport layer    3. Allows end-to-end communication
between two processes
4. Routes data from one network
node to the next
 A P-1, Q-4, R-3 B P-2, Q-4, R-1 C P-2, Q-3, R-1 D P-1, Q-3, R-2
Misc Topics in Computer Networks    GATE-CS-2004
Discuss it

Question 15 Explanation:
Data link layer is the second layer of the OSI Model. This layer is responsible for data transfer between nodes on the network and providing a point to point local delivery framework. So, P matches with 1. Network layer is the third layer of the OSI Model. This layer is responsible for forwarding of data packets and routing through intermediate routers. So, Q matches with 4. Transport layer is the fourth layer of the OSI Model. This layer is responsible for delivering data from process to process. So, R matches with 3.   Thus, A is the correct option.   Please comment below if you find anything wrong in the above post.
 Question 16
Which of the following is NOT true with respect to a transparent bridge and a router?
 A Both bridge and router selectively forward data packets B A bridge uses IP addresses while a router uses MAC addresses C A bridge builds up its routing table by inspect­ing incoming packets D A router can connect between a LAN and a WAN
Misc Topics in Computer Networks    GATE-CS-2004
Discuss it

 Question 17
The Boolean function x'y' + xy + x'y is equivalent to
 A x' + y' B x + y C x + y' D x' + y
Digital Logic & Number representation    GATE-CS-2004
Discuss it

Question 17 Explanation:
x’y’+xy+xy’ =(x’y’+y(x+x’)) =x'y’+y =x'+y Ans (d)
 Question 18
In an SR latch made by cross-coupling two NAND gates, if both S and R inputs are set to 0, then it will result in
 A Q = 0, Q' = 1 B Q = 1, Q' = 0 C Q = 1, Q' = 1 D Indeterminate states
Digital Logic & Number representation    GATE-CS-2004
Discuss it

Question 18 Explanation:
If both R reset and S set inputs are inactivated. It means made ‘0’, both Q and Q’ tend to be ‘1’. [NAND gate characteristic is that only when both inputs are 1,the output is 0.]  The logic of the circuit (Q’ is complement of Q) not satisfied, and the final state at an instant after inputs R and S changed to ‘0’, is only a matter of chance. Logic state is said to be indeterminate state or racing state. Each state, Q =‘1’and Q =‘0’, and Q =‘0’, Q=‘1’ trying to race through so “RACE CONDITION”  occurs and output become unstable. So ans is (D) part.
 Question 19
If 73x (in base-x number system) is equal to 54y (in base-y number system), the possible values of x and y are
 A 8, 16 B 10, 12 C 9, 13 D 8, 11
GATE-CS-2004    Number Representation
Discuss it

Question 19 Explanation:
We can solve it by converting both to decimals. 3 + 7*8 = 4 + 11*5
 Question 20
Which of the following addressing modes are suitable for program relocation at run time ?
(i)   Absolute addressing
(iv)  Indirect addressing
 A (i) and (iv) B (i) and (ii) C (ii) and (iii) D (i), (ii) and (iv)
GATE-CS-2004    Microprocessor
Discuss it

Question 20 Explanation:
Explanation: Program relocation at run time transfer complete block to some memory locations. This requires as base address and block should be relatively addressed through this base address .This require both base address and relative address. So( C)  is correct option. Absolute addressing mode and indirect addressing modes is used for one instruction at one time, not for whole block So both are not suitable for program relocation at run time.
 Question 21
The minimum number of page frames that must be allocated to a running process in a virtual memory environment is determined by
 A the instruction set architecture B page size C physical memory size D number of processes in memory
Memory Management    GATE-CS-2004
Discuss it

Question 21 Explanation:
There are two important tasks in virtual memory management: a page-replacement strategy and a frame-allocation strategy. Frame allocation strategy says gives the idea of minimum number of frames which should be allocated. The absolute minimum number of frames that a process must be allocated is dependent on system architecture, and corresponds to the number of pages that could be touched by a single (machine) instruction. So, it is instruction set architecture i.e. option (A) is correct answer. See Question 3 of http://www.geeksforgeeks.org/operating-systems-set-4/ Reference: https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/9_VirtualMemory.html This solution is contributed by Nitika Bansal
 Question 22
How many 8-bit characters can be transmitted per second over a 9600 baud serial communication link using asynchronous mode of transmission with one start bit, eight data bits, two stop bits, and one parity bit ?
 A 600 B 800 C 876 D 1200
Discuss it

Question 22 Explanation:
Background required - Physical Layer in OSI Stack In serial Communications, information is transferred in or out one bit at a time. The baud rate specifies how fast data is sent over a serial line. It’s usually expressed in units of bits-per-second (bps). Each block (usually a byte) of data transmitted is actually sent in a packet or frame of bits. Frames are created by appending synchronization and parity bits to our data.
"9600 baud" means that the serial port is capable of transferring a
maximum of 9600 bits per second.

Total Data To send = 1 bit(start) + 8 bits(char size) + 1 bit(Parity) + 2 bits(Stop)

= 12 bits.

Number of 8-bit characters that can be transmitted per second  = 9600/12 = 800.

This explanation is contributed by Pranjul Ahuja.
 Question 23
Identify the correct translation into logical notation of the following assertion.
"Some boys in the class are taller than all the girls"
Note : taller(x,y) is true if x is taller than y.
 A (∃x) (boy(x) → (∀y) (girl(y) ∧ taller(x,y))) B (∃x) (boy(x) ∧ (∀y) (girl(y) ∧ taller(x,y))) C (∃x) (boy(x) → (∀y) (girl(y) → taller(x,y))) D (∃x) (boy(x) ∧ (∀y) (girl(y) → taller(x,y)))
Propositional and First Order Logic.    GATE-CS-2004
Discuss it

Question 23 Explanation:
Now many people get confused when to use ∧ and when to use →. This question tests exactly that. We use ∧ when we want to say that the both predicates in this statement are always true, no matter what the value of x is. We use → when we want to say that although there is no need for left predicate to be true always, but whenever it becomes true, right predicate must also be true. D means there exist some boys x which taller than all girls y.
 Question 24
Consider the binary relation:
S = {(x, y) | y = x+1 and x, y ∈ {0, 1, 2, ...}}
The reflexive transitive closure of S is
 A {(x, y) | y > x and x, y ∈ {0, 1, 2, ... }} B {(x, y) | y ≥ x and x, y ∈ {0, 1, 2, ... }} C {(x, y) | y < x and x, y ∈ {0, 1, 2, ... }} D {(x, y) | y ≤ x and x, y ∈ {0, 1, 2, ... }}
Set Theory & Algebra    GATE-CS-2004
Discuss it

Question 24 Explanation:

Reflexive closure of a relation R on set S is the smallest reflexive relation which contains R.
If S = {(0, 1), (1, 2)} , we make it reflexive by taking its union with set {(0, 0), (1, 1), (2, 2)}. Thus, reflexive closure of S = {(0, 0), (0, 1), (1, 1), (1, 2), (2, 2)}.
Now transitive closure is defined as smallest transitive relation which contains S.
We check where does it violate property of transitivity then add appropriate pair. We have (0, 1) and (1, 2) but not (0, 2). So, S = {(0, 0), (0, 1), (0, 2), (1, 1), (1, 2), (2, 2)} now.

Thus, option (B) matches the final set S.

Please comment below if you find anything wrong in the above post.
 Question 25
If a fair coin is tossed four times. What is the probability that two heads and two tails will result?
 A 3/8 B 1/2 C 5/8 D 2/4
Probability    GATE-CS-2004
Discuss it

Question 25 Explanation:
There are total 16 possibilities, out of which following have 2 heads and 2 tails HHTT, HTHT, TTHH, THTH, HTTH, THHT So the probability of 2 heads is 6/16 which is 3/8
 Question 26
The number of different n × n symmetric matrices with each element being either 0 or 1 is: (Note: power(2, x) is same as 2x)
 A power(2, n) B power(2, n2) C power(2, (n2 + n)/2) D power(2, (n2 - n)/2)
Combinatorics    GATE-CS-2004
Discuss it

Question 26 Explanation:
We are considering a symmetric matrix (given in question). So, we need to look at half of elements ie. either upper or lower traingle i.e. A[i][j] = A[j][i] Hence, No. of elements = ( n^2 + n ) / 2 Since, we have only two elements : 0 & 1 No. of choices = 2 Therefore, No. of possibilities = 2 ^ (No. of elements) = 2 ^ ( ( n^2 + n ) / 2 ) = power ( 2 , ( n^2 + n ) / 2  )   This solution is contributed by Mohit Gupta.
 Question 27
Let A, B, C, D be n × n matrices, each with non-­zero determinant. If ABCD = 1, then B-1 is
 A D-1C-1A-1 B CDA C ADC D Does not necessarily exist
Linear Algebra    GATE-CS-2004
Discuss it

Question 27 Explanation:
This solution is contributed by Anil Saikrishna Devarasetty
 Question 28
What is the result of evaluating the following two expressions using three-digit floating point arithmetic with rounding?
(113. + -111.) + 7.51
113. + (-111. + 7.51) 
 A 9.51 and 10.0 respectively B 10.0 and 9.51 respectively C 9.51 and 9.51 respectively D 10.0 and 10.0 respectively
GATE-CS-2004    Number Representation
Discuss it

Question 28 Explanation:
(113. + -111.) + 7.51
= 2 + 7.51
= 9.51

113. + (-111. + 7.51)
= 113. + (-111. + 7.51)
= 113. - 103. = 10 [103.49 is rounded to 103.0]

 Question 29
The tightest lower bound on the number of comparisons, in the worst case, for comparison-based sorting is of the order of
 A n B n2 C n log n D n log2 n
GATE-CS-2004
Discuss it

Question 29 Explanation:
 Question 30
The problems 3-SAT and 2-SAT are
 A both in P B both NP-complete C NP-complete and in P respectively D undecidable and NP-complete respectively
GATE-CS-2004
Discuss it

Question 30 Explanation:
 Question 31
Consider the following C function:
int f(int n)
{
static int i = 1;
if (n >= 5)
return n;
n = n+i;
i++;
return f(n);
}

The value returned by f(1) is
 A 5 B 6 C 7 D 8
Recursion    GATE-CS-2004
Discuss it

Question 31 Explanation:
 Question 32
Consider the following program fragment for reversing the digits in a given integer to obtain a new integer. Let n = D1D2…Dm
int n, rev;
rev = 0;
while (n > 0)
{
rev = rev*10 + n%10;
n = n/10;
}

The loop invariant condition at the end of the ith iteration is:
 A n = D1D2….Dm-i and rev = DmDm-1…Dm-i+1 B n = Dm-i+1…Dm-1Dm and rev = Dm-1….D2D1 C n != rev D n = D1D2….Dm and rev = DmDm-1…D2D1
Misc    GATE-CS-2004
Discuss it

Question 32 Explanation:
The loop one by adds digits to rev starting from the last digit of n. It also removes digits from n starting from left.
 Question 33
Consider the following C program segment:
char p[20];
char *s = "string";
int length = strlen(s);
int i;
for (i = 0; i < length; i++)
p[i] = s[length — i];
printf("%s",p);

The output of the program is (GATE CS 2004)
 A gnirts B gnirt C string D no output is printed
GATE-CS-2004
Discuss it

Question 33 Explanation:
 Question 34
It is desired to design an object-oriented employee record system for a company. Each employee has a name, unique id and salary. Employees belong to different categories and their salary is determined by their category. The functions to get Name, getld and compute salary are required. Given the class hierarchy below, possible locations for these functions are: i. getld is implemented in the superclass ii. getld is implemented in the subclass iii. getName is an abstract function in the superclass iv. getName is implemented in the superclass v. getName is implemented in the subclass vi. getSalary is an abstract function in the superclass vii. getSalary is implemented in the superclass viii. getSalary is implemented in the subclass Choose the best design
 A (i), (iv), (vi), (viii) B (i), (iv), (vii) C (i), (iii), (v), (vi), (viii) D (ii), (v), (viii)
OOP Concepts    GATE-CS-2004
Discuss it

Question 34 Explanation:
 Question 35
Consider the label sequences obtained by the following pairs of traversals on a labeled binary tree. Which of these pairs identify a tree uniquely ?
(i)     preorder and postorder
(ii)    inorder and postorder
(iii)   preorder and inorder
(iv)   level order and postorder
 A (i) only B (ii), (iii) C (iii) only D (iv) only
Tree Traversals    GATE-CS-2004
Discuss it

Question 35 Explanation:
Here, we consider each and every option to check whether it is true or false. 1) Preorder and postorder For the above trees, Preorder is AB Postorder is BA It shows that preorder and postorder can’t identify a tree uniquely. 2) Inorder and postorder define a tree uniquely 3) Preorder and Inorder also define a tree uniquely 4) Levelorder and postorder can’t define a tree uniquely. For the above example, Level order is AB Postorder is BA See http://www.geeksforgeeks.org/if-you-are-given-two-traversal-sequences-can-you-construct-the-binary-tree/ for details This solution is contributed by Anil Saikrishna Devarasetty
 Question 36
A circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To which node should p point such that both the operations enQueue and deQueue can be performed in constant time?
 A rear node B front node C not possible with a single pointer D node next to front
GATE-CS-2004
Discuss it

Question 36 Explanation:
 Question 37
The elements 32, 15, 20, 30, 12, 25, 16 are inserted one by one in the given order into a Max Heap. The resultant Max Heap is.
 A a B b C c D d
GATE-CS-2004
Discuss it

Question 37 Explanation:
A max heap is a complete binary tree in which the value of each non-leaf node is greater than or equal to the values of its children. For the given case, first insert all the values in a complete binary tree. Then, we apply shifting. What we do is we start with the bottom most non-leaf node. If it is smaller than any (or both) of the child nodes, we swap it with the largest child. Doing the same way, we continue to move upwards the tree until all the non-leaf nodes satisfy the properties of the max heap.   So, the first time we make a complete binary tree, we have

32

/            \

15              20

/    \          /     \

30      12       25      16


Now, we need to swap 15 with 30 and 20 with 25.

32

/            \

30              25

/    \          /     \

15      12       20      16


This is the required max heap, and matches with option A.
So, A is the correct choice.

Please comment below if you find anything wrong in the above post.
 Question 38
Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is
 A abc × + def ^ ^ - B abc × + de ^ f ^ - C ab + c × d - e ^ f ^ D - + a × bc ^ ^ def
Stack    GATE-CS-2004
Discuss it

Question 38 Explanation:
^ is right assosciative. See http://geeksquiz.com/stack-set-2-infix-to-postfix/ This solution is contributed by parul Sharma.
 Question 39
Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will be
 A best if A is in row-major, and B is in column- major order B best if both are in row-major order C best if both are in column-major order D independent of the storage scheme
Analysis of Algorithms    GATE-CS-2004
Discuss it

Question 39 Explanation:
This is a trick question. Note that the questions asks about time complexity, not time taken by the program. for time complexity, it doesn't matter how we store array elements, we always need to access same number of elements of M1 and M2 to multiply the matrices. It is always constant or O(1) time to do element access in arrays, the constants may differ for different schemes, but not the time complexity.
 Question 40
Suppose each set is represented as a linked list with elements in arbitrary order. Which of the operations among union, intersection, membership, cardinality will be the slowest?
 A union only B intersection, membership C membership, cardinality D union, intersection
GATE-CS-2004
Discuss it

Question 40 Explanation:
 Question 41
Consider the following C program
main()
{
int x, y, m, n;
scanf ("%d %d", &x, &y);
/* Assume x > 0 and y > 0  */
m = x;
n = y;
while (m! = n)
{
if (m > n)
m = m - n;
else
n = n - m;
}
print f ("% d", n);
}

The program computes
 A x ÷ y using repeated subtraction B x mod y using repeated subtraction C the greatest common divisor of x and y D the least common multiple of x and y
Misc    GATE-CS-2004
Discuss it

Question 41 Explanation:
The given program is iterative implementation of Euclid's Algorithm for GCD
 Question 42
What does the following algorithm approximate?
    x = m;
y = 1;
while (x - y > e)
{
x = (x + y)/2;
y = m/x;
}
print(x);

(Assume m > 1, e > 0).
 A log m B m2 C m1/2 D m1/3
Misc    GATE-CS-2004
Discuss it

Question 42 Explanation:
The given code is implementation of Babylonian method for square root
 Question 43
Consider the following C program segment
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
 A The number of leaf nodes in the tree B The number of nodes in the tree C The number of internal nodes in the tree D The height of the tree
GATE-CS-2004
Discuss it

Question 43 Explanation:
DoSomething() returns max(height of left child + 1, height of right child + 1). So given that pointer to root of tree is passed to DoSomething(), it will return height of the tree. Note that this implementation follows the convention where height of a single node is 0. Lets take a sample tree and try to run the code. The above tree returns 3 as output which is the height of the tree (with the convention of height of single node as 0) whereas the number of leaf nodes in this tree are 4, number ofinternal nodes are 4 and total nodes are 8 which clearly proves the other options wrong. Please refer http://geeksquiz.com/data-structures-binary-trees-question-23/ This solution is contributed by Parul Sharma.
 Question 44
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?
 A P, Q, R, S, T, U B P, Q, R, U, S, T C P, Q, R, U, T, S D P, Q, T, R, U, S
GATE-CS-2004
Discuss it

Question 44 Explanation:
Please refer Dijkstra’s shortest path algorithm This solution is contributed by Parul Sharma.
 Question 45
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.
 A 200 B 180 C 160 D 40
Parsing and Syntax directed translation    GATE-CS-2004
Discuss it

Question 45 Explanation:
 Question 46
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 ?
 A 5.5 B 5.75 C 6 D 6.25
GATE-CS-2004    CPU Scheduling
Discuss it

Question 46 Explanation:
The following is Gantt Chart of execution
 P1 P2 P4 P3 P1 1 4 5 8 12
Turn Around Time = Completion Time - Arrival Time   Avg Turn Around Time  =  (12 + 3 + 6+  1)/4 = 5.50
 Question 47
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?
 A 645 nanoseconds B 1050 nanoseconds C 1215 nanoseconds D 1230 nanoseconds
Memory Management    GATE-CS-2004
Discuss it

Question 47 Explanation:

Figure : Translation Lookaside Buffer[5]

As shown in figure, to find frame number for corresponding page number, at first TLB (Translation Lookaside Buffer) is checked whether it has that desired page number- frame number pair entry or not, if yes then it’s TLB hit otherwise it’s TLB miss. In case of miss the page number is searched into page table. In two-level paging scheme, the memory is referred two times to obtain corresponding frame number.

If a virtual address has no valid entry in the page table, then any attempt by your pro- gram to access that virtual address will cause a page fault to occur .In case of page fault, the required frame is brought in main memory from secondary memory,time taken to service the page fault is called page fault service time.

We have to caculate average execution time(EXE), lets suppose average memory ac- cess time to fetch is M, then EXE = 100ns + 2*150 (two memory references to fetch instruction) + M ...1

Now we have to calculate average memory access time M, since page fault is 1 in 10,000 instruction and then M = (1 1/104 )(M EM ) + (1/104) 8ms ...2

Where MEM is memory access time when page is present in memory. Now we calcu- late MEM MEM = .9(TLB Access Time)+.1(TLB Access Time+2*150ns)

Here TLB Acess Time is not given lets assume it 0. So MEM=.9(0)+.1(300ns) =30ns , put MEM value in equation(2). M = (1 1/104 )(30ns) + (1/104 ) 8ms = 830ns

Put this M's value in equation(1), EXE=100ns+300ns+830ns=1230ns , so Ans is option(4).

This sulotion is contributed Nirmal Bhardwaj .

 Question 48
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 semaphone 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
 A P(SY), P(SX); P(SX), P(SY) B P(SX), P(SY); P(SY), P(SX) C P(SX), P(SX); P(SY), P(SY) D P(SX), P(SY); P(SX), P(SY)
Process Management    GATE-CS-2004
Discuss it

Question 48 Explanation:
Option A: In line L1 ( p(Sy) ) i.e. process p1 wants lock on Sy that is
held by process p2 and line L3 (p(Sx)) p2 wants lock on Sx which held by p1.
So here circular and wait condition exist means deadlock.

Option B : In line L1 ( p(Sx) ) i.e. process p1 wants lock on Sx that is held
by process p2 and line L3 (p(Sy)) p2 wants lock on Sx which held by p1. So here
circular and wait condition exist means deadlock.

Option C: In line L1 ( p(Sx) ) i.e. process p1 wants lock on Sx and line L3 (p(Sy))
p2 wants lock on Sx . But Sx and Sy can’t be released by its processes p1 and p2.

 Question 49
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 ?
 A 224 bytes B 232 bytes C 234 bytes D 248 bytes
Input Output Systems    GATE-CS-2004
Discuss it

Question 49 Explanation:
Image Source: Wiki
Size of Disk Block = 1Kbyte

but 48 bit integers are used for address
Therefore address size = 6 bytes

No of addresses per block = 1024/6  = 170.66
Therefore 170 ≈ 2^8 addresses per block can be stored

Maximum File Size = 10 Direct + 1 Single Indirect +
1 Double Indirect + 1 Triple Indirect
= 10 + 28 + 28*28 + 28*28*28
≈ 224 Blocks

Since each block is of size 210

Maximum files size = 224 * 210
= 234    
 Question 50
The relation scheme Student Performance (name, courseNo, rollNo, grade) has the following functional dependencies:
name, courseNo → grade
name → rollNo
rollNo → name 
The highest normal form of this relation scheme is
 A 2 NF B 3 NF C BCNF D 4NF
Database Design(Normal Forms)    GATE-CS-2004
Discuss it

Question 50 Explanation:
For easy understanding let's say attributes (name, courseNo, rollNo, grade)
be (A,B,C,D)

Then given FDs are as follows:
AB->D, CB->D, A->C, C->A

Here there are two Candidate keys, AB and CB.

Now AB->D and CB->D satisfy BCNF as LHS is superkey in both.

But, A->C and C->A, doesn't satisfy BCNF. Hence we check for 3NF for
these 2 FDs.

As C and A on RHS of both the FDs are prime attributes, they satisfy 3NF.

Hence for the whole relation the highest normal form is 3NF. 
 Question 51
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). The condition in join is "(sex = female ^ x = male ^ marks ≤ m)"
 A names of girl students with the highest marks B names of girl students with more marks than some boy student C names of girl students with marks not less than some boy students4) D names of girl students with more marks than all the boy students
Database Design(Normal Forms)    GATE-CS-2004
Discuss it

Question 51 Explanation:
The above relational algebra expression has two sub expressions.
The first one takes as input the Student relation (Student) and filters
out all the tuples where sex=female(r sex=female (Student))
and then projects their names (P name r sex=female (Student)).
So we get a new relation with names of all the female students.

The second one takes as input the Student relation and performs a rename
operation on one with attributes name, sex and marks renamed as n, x, m
respectively (r n, x, m(Student)) and then followed by a self-Cartesian
product on the Student relation. The condition (sex = female ^ m = male ^ marks ≤ m)
filters tuples with all female students from the first relation,
male students from the second relation and performs a Cartesian product where
marks of the female student is either less than or equal to a male student and
then projects their names. So we get a new relation with names of all female
students whose marks are lesser than at least one of the male student.

The difference operator(-) between the two subexpressions gives the names of all female students whose marks are more than all male students of the class. (From all the female students’ names we remove all those whose marks are at least more the one male student) This explanation has been contributed by Yashika Arora.
 Question 52
The order of an internal node in a B+ tree index is the maximum number of children it can have. Suppose that a child pointer takes 6 bytes, the search field value takes 14 bytes, and the block size is 512 bytes. What is the order of the internal node?
 A 24 B 25 C 26 D 27
B and B+ Trees    GATE-CS-2004
Discuss it

Question 52 Explanation:

Key size = 14 bytes (given) Child pointer = 6 bytes (given)
We assume the order of B+ tree to be ‘n’.
Block size = (n - 1) * key size + n * child pointer 512 >= (n - 1) * 14 + n * 6 512 >= 14 * n – 14 + 6 * n n = (512 + 14) / 20 n = 526 / 20 n = 26.3 n = 26

Thus, option (C) is correct.

Please comment below if you find anything wrong in the above post.
 Question 53
The employee information in a company is stored in the relation
Employee (name, sex, salary, deptName)
Consider the following SQL query
select deptName
from Employee
where sex = 'M'
group by deptName
having avg (salary) > (select avg (salary) from Employee)

It returns the names of the department in which
 A the average salary is more than the average salary in the company B the average salary of male employees is more than the average salary of all male employees in the company C the average salary of male employees is more than the average salary of employees in the same department D the average salary of male employees is more than the average salary in the company
SQL    GATE-CS-2004
Discuss it

Question 53 Explanation:
In this SQL query, we have
select deptName ---------------  Select the department name
from Employee  ----------------  From the database of employees
where sex = 'M' ---------------  Where sex is male (M)
group by deptName -------------  Group by the name of the department
having avg (salary) >
(select avg (salary) from Employee)  -----  Having the average salary
greater than the average salary
of all employees in the organization.

So, this query would return the name of all departments in which the average salary of male employees is greater than the average salary of all employees in the company. Hence, D is the correct choice.   Please comment below if you find anything wrong in the above post.
 Question 54
A and B are the only two stations on an Ethernet. Each has a steady queue of frames to send. Both A and B attempt to transmit a frame, collide, and A wins the first backoff race. At the end of this successful transmission by A, both A and B attempt to transmit and collide. The probability that A wins the second backoff race is:
 A 0.5 B 0.625 C 0.75 D 1
Discuss it

Question 54 Explanation:
This is basically the question related to unfairness of exponential back-off algorithm called 'capture effect'. You can find more info about it here: http://intronetworks.cs.luc.edu/current/html/ethernet.html#capture-effect The solution to the above problem goes like this: At every attempt to transit a frame, both A and B chooses value of 'k' randomly. Based on the value of 'k', back-off time is calculated as a multiple of 'k'. The station or node having the smaller back-off time gets to send the frames eariler. 1st attempt: Value of 'k' would be k=0 or k=1 (0 <= k <= 2^n-1; where n=nth attempt). Since A won the first race, A must have chosen k=0 and B must have chosen k=1 (A wins here with probability 0.25). As A won, A will again choose k=0 or k=1 for its 2nd frame, but B will choose k=0,1,2 or 3 as B failed to send its first frame in the first attempt. 2nd attempt: Let kA= value of k chosen by A and kB = value of k chosen by B. We will use notation (kA,kB) to show the possible values. Now the sample space for the 2nd attempt is (kA,kB) = (0,0),(0,1),(0,2),(0,3),(1,0),(1,1),(1,2) or (1,3) i.e. 8 possible outcomes. For A to win, kA should be less than kB (kA < kB). Thus, our event space is (kA, kB) = (0,1),(0,2),(0,3),(1,2),(1,3) i.e. 5 possible outcomes. Thus the probability that A wins the 2nd back-off race = 5/8 = 0.625
 Question 55
The routing table of a router is shown below:
 Destination     Sub net mask 	     Interface
128.75.43.0 	 255.255.255.0 	        Eth0
128.75.43.0 	 255.255.255.128 	Eth1
192.12.17.5 	 255.255.255.255 	Eth3
default 	  	                Eth2
On which interfaces will the router forward packets addressed to destinations 128.75.43.16 and 192.12.17.10 respectively?
 A Eth1 and Eth2 B Eth0 and Eth2 C Eth0 and Eth3 D Eth1 and Eth3
Network Layer    GATE-CS-2004
Discuss it

Question 55 Explanation:
To find the interface, we need to do AND of incoming IP address and Subnet mask. Compare the result of AND with the destination. Note that if there is a match between multiple Destinations, then we need to select the destination with longest length subnet mask. 128.75.43.16, matches with 128.75.43.0 and 128.75.43.0, the packet is forwarded to Eth1 as length of subnet mask in Eth11 is more. If a result is not matching with any of the given destinations then the packet is forwarded to the default interface (here Eth2). Therefore the packet's addressed to 192.12.17.10 will be forwarded to Eth2.
 Question 56
Consider three IP networks A, B and C. Host HA in network A sends messages each containing 180 bytes of application data to a host HC in network C. The TCP layer prefixes a 20 byte header to the message. This passes through an intermediate net­work B. The maximum packet size, including 20 byte IP header, in each network is A : 1000 bytes B : 100 bytes C : 1000 bytes The network A and B are connected through a 1 Mbps link, while B and C are connected by a 512 Kbps link (bps = bits per second). Assuming that the packets are correctly delivered, how many bytes, including headers, are delivered to the IP layer at the destination for one application message, in the best case ? Consider only data packets.
 A 200 B 220 C 240 D 260
Network Layer    GATE-CS-2004
Discuss it

Question 56 Explanation:
 Question 57
Consider three IP networks A, B and C. Host HA in network A sends messages each containing 180 bytes of application data to a host HC in network C. The TCP layer prefixes a 20 byte header to the message. This passes through an intermediate net­work B. The maximum packet size, including 20 byte IP header, in each network is A : 1000 bytes B : 100 bytes C : 1000 bytes The network A and B are connected through a 1 Mbps link, while B and C are connected by a 512 Kbps link (bps = bits per second). What is the rate at which application data is transferred to host HC? Ignore errors, acknowledgements, and other overheads.
 A 325.5 Kbps B 354.5 Kbps C 409.6 Kbps D 512.0 Kbps
Network Layer    GATE-CS-2004
Discuss it

Question 57 Explanation:
Host C receives 260 bytes of data (including headers) out of which 180 bytes is of application data. Thus the efficiency is 180/260 = 0.6923. Thus the rate at which application data is transferred to host C would be 0.6923 * 512 Kbps = 354.45 Kbps. ( How host C receives 260 bytes of data is shown here: http://geeksquiz.com/gate-gate-cs-2004-question-56/
 Question 58
A circuit outputs a digit in the form of 4 bits. 0 is represented by 0000, 1 by 0001, ..., 9 by 1001. A combinational circuit is to be designed which takes these 4 bits as input and outputs 1 if the digit ≥ 5, and 0 otherwise. If only AND, OR and NOT gates may be used, what is the minimum number of gates required?
 A 2 B 3 C 4 D 5
Digital Logic & Number representation    GATE-CS-2004
Discuss it

Question 58 Explanation:
We should get output 1 for values>=5 Making truth table for problem
 A B C D Op 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0 0 1 1 1 0 1 0 X 1 0 1 1 X 1 1 0 0 X 1 1 0 1 X 1 1 1 0 X 1 1 1 1 X
Putting this in kmap and solving   Here crucial point is that we need to make pair of 8 elements using don’t cares also…so final expression is A+BD+BC
• A+B(C+D)
Hence we’ll use two OR gate and one AND gate so total 3 gates. Ans (B) part.
 Question 59
Which are the essential prime implicants of the following Boolean function? f(a, b, c) = a'c + ac' + b'c
 A a'c and ac' B a'c and b'c C a'c only D ac' and bc'
Digital Logic & Number representation    GATE-CS-2004
Discuss it

Question 59 Explanation:
Essential prime implicants are prime implicants that cover an output of the function that no combination of other prime implicants is able to cover i.e., if we delete such elements then the property of group, quad, octet is destroyed. By drawing k map and by putting c on left side and a, b on right side we can find that a'c and ac' are essential prime implicants.
 Question 60
Consider a multiplexer with X and Y as data inputs and Z as control input. Z = 0 selects input X, and Z = 1 selects input Y. What are the connections required to realize the 2-variable Boolean function f = T + R, without using any additional hardware ?
 A R to X, 1 to Y, T to Z B T to X, R to Y, T to Z C T to X, R to Y, 0 to Z D R to X, 0 to Y, T to Z
Digital Logic & Number representation    GATE-CS-2004
Discuss it

Question 60 Explanation:
For mux we will be having equation like z’x+zy-----(1) Now putting X=R , Y=1 and Z=T  in eq(1) we find----
• T’R+T(1)
• T+T’R
• T+R (SINCE a+a’b=a+b)
So ans is (A) part.
 Question 61
Consider the partial implementation of a 2-bitt counter using T flip-flops following the sequence 0-2-3-1-0, as shown below To complete the circuit, the input X should be 1) 2) 3) 4)
 A Q2' B Q2 + Q1 C (Q1 ⊕ Q2)' D Q1 ⊕ Q2
Digital Logic & Number representation    GATE-CS-2004
Discuss it

Question 61 Explanation:
From circuit we see T1=XQ1’+X’Q1----(1) AND T2=(Q2+Q1)’----(2) AND DESIRED OUTPUT IS 00->10->11->01->00 SO X SHOULD BE Q1Q2’+Q1’Q2 SATISFYING 1 AND 2. SO ANS IS (D) PART.
 Question 62
A 4-bit carry lookahead adder, which adds two 4-bit numbers, is designed using AND, OR, NOT, NAND, NOR gates only. Assuming that all the inputs are available in both complemented and uncomplemented forms and the delay of each gate is one time unit, what is the overall propagation delay of the adder? Assume that the carry network has been implemented using two-level AND-OR logic.
 A 4 time units B 6 time units C 10 time units D 12 time units
Digital Logic & Number representation    GATE-CS-2004
Discuss it

Question 62 Explanation:
Let the input carry to the first adder be denoted by C1. Now, to calculate C2 we need = P1C1 + G1 = 4 gate levels (P1 takes 2 gate levels) to calculate S1 we need = P1 XOR C1 = 2 + 2 = 4 gate levels. Since it is a Carry look ahead adder, computing C3 , S2 doesn't have to wait for carry output C2 from the previous adder as C2, C3 etc will get computed at the same time. Now, S2 is computed as = P2 XOR C2 = P2.C2' + P2'.C2 = P2 (P1.C1 + G1 )' + P2' (P1.C1 + G1) [ notice that we are not using the output carry from first adder C2 anywhere here ] which can be implemented using 4 gate levels. also C3 can be computed by using 4 gate levels and so on... so the overall propagation delay is 4 gate level as the outputs at Si , Ci are available at the respective full adders after 4 gate levels = 4 time units. To understand it with more clarity draw the carry look ahead adder circuit and then check it.
 Question 63
Directions for question 63 to 64: Consider the following program segment for a hypothetical CPU having three user registers R1, R2 and R3.
 Instruction 	 Operation 	 Instruction Size(in words)
MOV R1,5000; 	 R1 ¬ Memory[5000] 	 2
MOV R2, (R1); 	 R2 ¬ Memory[(R1)] 	 1
ADD R2, R3; 	 R2 ¬ R2 + R3 	         1
MOV 6000, R2; 	 Memory [6000] ¬ R2 	 2
HALT 	         Machine halts 	         1 
Consider that the memory is byte addressable with size 32 bits, and the program has been loaded starting from memory location 1000 (decimal). If an interrupt occurs while the CPU has been halted after executing the HALT instruction, the return address (in decimal) saved in the stack will be
 A 1007 B 1020 C 1024 D 1028
GATE-CS-2004    Microprocessor
Discuss it

Question 63 Explanation:
Instruction size are given in words. So first instruction will take 2 words i.e 8 bytes(as 32 bit byte addressable, word size will be 32 bit ) so on for 2nd instruction 4 byte, for 3rd 4 bytes, 4th 8 bytes..5th 4 bytes. As 1st instruction starts from 1000 and the size is 8 bytes second instruction address will be 1008, like wise 3rd instruction address will be 1012,4th instruction address 1016,5th instruction address 1024 and halt instruction address will be 1028. As an interrupt occurs executing the HALT instruction, the return address (in decimal) saved in the stack will be the address of the halt instruction ..so answer is 1028.
 Question 64
Directions for question 63 to 64: Consider the following program segment for a hypothetical CPU having three user registers R1, R2 and R3.
 Instruction 	 Operation 	 Instruction Size(in words)
MOV R1,5000; 	 R1 ¬ Memory[5000] 	 2
MOV R2, (R1); 	 R2 ¬ Memory[(R1)] 	 1
ADD R2, R3; 	 R2 ¬ R2 + R3 	         1
MOV 6000, R2; 	 Memory [6000] ¬ R2 	 2
HALT 	         Machine halts 	         1
Let the clock cycles required for various operations be as follows: Register to/ from memory transfer: 3 clock cycles ADD with both operands in register : 1 clock cycle Instruction fetch and decode : 2 clock cycles per word The total number of clock cycles required to execute the program is
 A 29 B 24 C 23 D 20
GATE-CS-2004    Microprocessor
Discuss it

Question 64 Explanation:
The clock cycles are per block; if an instruction size is 2 then it requires twice no. of clock cycles.
 Instruction no.       size                                              no. of clock cycles 1                                2                                                                       3*2+2 2                                1                                                                       1*3+2 3                                1(add only)                                                      1 4                                2                                                                       3*2+2 5                                1                                                                       2(fetch and decode) Total                                                                  24
 Question 65
Consider a small two-way set-associative cache memory, consisting of four blocks. For choosing the block to be replaced, use the least recently used (LRU) scheme. The number of cache misses for the following sequence of block addresses is 8, 12, 0, 12, 8
 A 2 B 3 C 4 D 5
GATE-CS-2004
Discuss it

Question 65 Explanation:
8, 12, 0, 12, 8

Miss 8
Miss 12
Miss 0

No miss for 12
No miss for 8
 Question 66
The microinstructions stored in the control memory of a processor have a width of 26 bits. Each microinstruction is divided into three fields: a micro-operation field of 13 bits, a next address field (X), and a MUX select field (Y). There are 8 status bits in the inputs of the MUX. How many bits are there in the X and Y fields, and what is the size of the control memory in number of words?
 A 10, 3, 1024 B 8, 5, 256 C 5, 8, 2048 D 10, 3, 512
GATE-CS-2004    Microprocessor
Discuss it

Question 66 Explanation:
MUX has 8 states bits as input lines so we require 3 select inputs to select and input lines. No. of bits in control memory next address field=26-13-3 =10 10 bit addressing .we have 2 10 memory size So X,Y size=10,3 So (A) is correct option.
 Question 67
A hard disk with a transfer rate of 10 Mbytes/ second is constantly transferring data to memory using DMA. The processor runs at 600 MHz, and takes 300 and 900 clock cycles to initiate and complete DMA transfer respectively. If the size of the transfer is 20 Kbytes, what is the percentage of processor time consumed for the transfer operation ?
 A 5.0% B 1.0% C 0.5% D 0.1%
Input Output Systems    GATE-CS-2004
Discuss it

Question 67 Explanation:
Transfer rate=10 MB per second Data=20 KB=20* 2 10 So Time=(20 * 2 10)/(10 * 2 20)= 2* 10-3 =2 ms Processor speed= 600 MHz=600 Cycles/sec Cycles required by CPU=300+900 =1200 For DMA=1200 So time=1200/(600 *10 6)=.002 ms  In %=.002/2*100=.1% So (D) is correct option
 Question 68
Let A = 1111 1010 arid B = 0000 1010 be two 8-bit 2's complement numbers. Their product in 2's complement is
 A 1100 0100 B 1001 1100 C 1010 0101 D 1101 0101
GATE-CS-2004    Number Representation
Discuss it

Question 68 Explanation:
Here, we have A = 1111 1010 =  - 610 (A is a 2's complement number) B = 0000 1010 =  1010 (B is a 2's complement number)   A x B = - 6010 = 1 011 11002 = 1 100 0011 (1's complement) = 1 100 0100 (2's complement)   Thus, the product of A and B in 2's complement is 1100 0100, which is option A. So, A is the correct option.   Please comment below if you find anything wrong in the above post.
 Question 69
A 4-stage pipeline has the stage delays as 150, 120, 160 and 140 nanoseconds respectively. Registers that are used between the stages have a delay of 5 nanoseconds each. Assuming constant clocking rate, the total time taken to process 1000 data items on this pipeline will be
 A 120.4 microseconds B 160.5 microseconds C 165.5 microseconds D 590.0 microseconds
Computer Organization and Architecture    GATE-CS-2004
Discuss it

Question 69 Explanation:
Delay between each stage is 5 ns.
Total delay in pipline = 150 + 120 + 160 + 140 = 570
Total delay for one data item = 570 + 5*3 (Note that there are 3 intermediate registers)
= 585
For 1000 data items, first data will take 585 ns to complete and rest
999 data will take max of all the stages that is 160 ns + 5 ns register delay

Total Delay = 585 + 999*165 ns which is approximately 165.5 microsecond. 
 Question 70
The following propositional statement is (P → (Q v R)) → ((P ^ Q) → R)
 A satisfiable but not valid B valid C a contradiction D none of the above
Propositional and First Order Logic.    GATE-CS-2004
Discuss it

Question 70 Explanation:
We create the truth table for given statement S as : A formula is satisfiable if there is atleast one assignment for which it is true. Clearly this formula is satisfiable as there are 7 assignments for which it is true. A formula is valid if it is true for all assignments, which is not the case here. Thus, option (A) is correct. Please comment below if you find anything wrong in the above post.
 Question 71
How many solutions does the following system of linear equations have ?
  -x + 5y = -1
x - y = 2
x + 3y = 3
 A infinitely many B two distinct solutions C unique D none of these
Linear Algebra    GATE-CS-2004
Discuss it

Question 71 Explanation:
This solution is contributed by Anil Saikrishna Devarasetty.
 Question 72
The following is the incomplete operation table a 4-element group.


*
e
a
b
c

e
e
a
b
c

a
a
b
c
e

b

c


The last row of the table is
 A c a e b B c b a e C c b e a D c e a b
Set Theory & Algebra    GATE-CS-2004
Discuss it

Question 72 Explanation:
It is given that the given set of 4 elements is group. The element 'e' is clearly identity as the row corresponding to it has all values same as the other operand. Also, since a*c is e, c*a should also be e which is only the case in option D
 Question 73
The inclusion of which of the following sets into
S = {{1, 2}, {1, 2, 3}, {1, 3, 5}, (1, 2, 4), (1, 2, 3, 4, 5}}
is necessary and sufficient to make S a complete lattice under the partial order defined by set containment ?
 A {1} B {1}, {2, 3} C {1}, {1, 3} D {1}, {1, 3}, (1, 2, 3, 4}, {1, 2, 3, 5)
Set Theory & Algebra    GATE-CS-2004
Discuss it

Question 73 Explanation:
• A partially ordered set L is called a complete lattice if every subset M of L has a least upper bound called as supremum and a greatest lower bound called as infimum.
• We are given a set containment relation.
• So, supremum element is union of all the subset and infimum element is intersection of all the subset.
• Set S is not complete lattice because although it has a supremum for every subset, but some subsets have no infimum. We take subset {{1,3,5},{1,2,4}}.Intersection of these sets is {1}, which is not present in S. So we have to add set {1} in S to make it a complete lattice
Thus, option (A) is correct. Please comment below if you find anything wrong in the above post.
 Question 74
An examination paper has 150 multiple-choice questions of one mark each, with each question having four choices. Each incorrect answer fetches -0.25 mark. Suppose 1000 students choose all their answers randomly with uniform probablity. The sum total of the expected marks obtained by all these students is:
 A 0 B 2550 C 7525 D 9375
Probability    GATE-CS-2004
Discuss it

Question 74 Explanation:
Expected marks per question is = -0.25 * 3/4 + 1 * 1/4 = 1/16
Since choice is uniformly distributed, expected marks = 150*1000/16 = 9375
 Question 75
Mala has a colouring book in which each English letter is drawn two times. She wants to paint each of these 52 prints with one of k colours, such that the colour-pairs used to colour any two letters are different. Both prints of a letter can also be coloured with the same colour. What is the minimum value of k that satisfies this requirement ?
 A 9 B 8 C 7 D 6
Combinatorics    GATE-CS-2004
Discuss it

Question 75 Explanation:
This question is slightly ambiguous. So first let us understand what question is asking. So in a book, we have letters A-Z and each letter is printed twice, so there are 52 letters. Now we have to color each letter, so we need a pair of colors for that, because each letter is printed twice. Also in a pair, both colors can be some. Now condition is that a pair of colors can't be used more than once. So suppose Mala has 3 colors : Red, Blue, Green. She can color as follows : (A,A) : (Red,Red), (B,B) : (Blue,Blue), (C,C) : (Green,Green), (D,D) : (Red,Blue), (E,E) : (Red,Green), (F,F) : (Blue,Green). Now we don't have more pairs of colors left, we have used all pairs, but could color only 6 letters out of 26. So question is to find minimum no. of colors, so that we could color all 26 letters. So if Mala has k colors, she can have k pairs of same colors, thus coloring k letters, then kC2 other pairs of colors, thus coloring kC2 more letters. So total no. of letters colored = k+kC2=k+k(k1)2=k(k+1)2. So we want k(k+1)226 i.e. k(k+1)52, so k7, so option (C) is correct. Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2004.html
 Question 76
In an M'N matrix such that all non-zero entries are covered in a rows and b columns. Then the maximum number of non-zero entries, such that no two are on the same row or column, is
 A ≤ a + b B ≤ max {a, b} C ≤ min {M-a, N-b} D ≤ min {a, b}
Linear Algebra    GATE-CS-2004
Discuss it

Question 76 Explanation:
Suppose a < b, for example let a = 3, b= 5, then we can put non-zero entries only in 3 rows and 5 columns. So suppose we put non-zero entries in any 3 rows in 3 different columns. Now we can't put any other non-zero entry anywhere in matrix, because if we put it in some other row, then we will have 4 rows containing non-zeros, if we put it in one of those 3 rows, then we will have more than one non-zero entry in one row, which is not allowed. So we can fill only "a" non-zero entries if a < b, similarly if b < a, we can put only "b" non-zero entries. So answer is ≤min(a,b), because whatever is less between a and b, we can put atmost that many non-zero entries. So option (D) is correct. Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2004.html
 Question 77
The minimum number of colours required to colour the following graph, such that no two adjacent vertices are assigned the same colour, is
 A 2 B 3 C 4 D 5
Graph Theory    GATE-CS-2004
Discuss it

Question 77 Explanation:
Two vertices are said to be adjacent if they are directly connected, i.e., there is a direct edge between them. So, here, we can assign same color to 1 & 2 (red), 3 & 4 (grey), 5 & 7 (blue) and 6 & 8 (brown). Therefore, we need a total of 4 distinct colors. Thus, C is the correct choice.

Please comment below if you find anything wrong in the above post.
 Question 78
Two n bit binary strings, S1 and S2, are chosen randomly with uniform probability. The probability that the Hamming distance between these strings (the number of bit positions where the two strings differ) is equal to d is
 A nCd /2n B nCd / d C d/2n D 1/2d
Probability    GATE-CS-2004
Discuss it

Question 78 Explanation:
There are two string s1 and s2, so probability of selection of any one is 1/2. Length of string is n bit and hamming distance is d bit so applying binomial distribution- nCd(1/2)^d(1/2)^n - d = nCd(1/2)^d+n-d = nCd /2n
 Question 79
How many graphs on n labeled vertices exist which have at least (n2 - 3n)/2 edges ?
 A A B B C C D D
Set Theory & Algebra    GATE-CS-2004
Discuss it

Question 79 Explanation:

Let there be total number of edges of a graph to be formed be e and total number of vertices be n.

So the total number of ways a graph can be formed having exactly e edges and v vertices is given by the total number of ways we can select e edges among v edges

i. e.

C (v, e)

Now, here e = (n2 – 3n)/2 and v = n(n-1)/2 (maximum number of edges in a simple graph).

So to select a edge we can do that in C (v, (n2 – 3n)/2) ways.

Since minimum no. of edges to be selected for a graph are (n2 – 3n)/2.

So total number of graphs possible will be :

C(v, e) + C(v, e+1) + C(v, e+2) +…………...+ C(v, v).

C(v, v-e) + C(v, v-(e+1)) + C(v, v-(e+2)) +…………...+ C(v, v-v).

Since v - e = n(n-1)/2 - (n2 – 3n)/2 = n

Therefore

C(v, n) + C(v, n-1) + C(v, n-2) +…………...+ C(v, 0).

Solving this we will get

This solution is contributed by Namita Singh.

 Question 80
A point is randomly selected with uniform probability in the X-Y plane within the rectangle with corners at (0,0), (1,0), (1,2) and (0,2). If p is the length of the position vector of the point, the expected value of p2 is
 A 2/3 B 1 C 4/3 D 5/3
Probability    GATE-CS-2004
Discuss it

Question 80 Explanation:
Here minimum value of p can be 0 (if point chosen is (0,0), then length of position vector will be 0), and maximum value can be 5√ when point chosen is (1,2), because that is the farthest point from origin. So p can vary from 0 to 5√. Now we know that [Tex]E(p^2) = \int^\sqrt{5}_0 p^2*P(p)\,dp[/Tex] Since p is a uniform random variable, [Tex]P(p) = \frac{1}{\sqrt{5}-0} = \frac{1}{\sqrt{5}}[/Tex] So [Tex]E(p^2) = \frac{1}{\sqrt{5}}\left[\frac{p^3}{3}\right]^{\sqrt{5}}_0 = \frac{5}{3}[/Tex] So option (D) is correct. Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2004.html
 Question 81
Let G1 = (V, E1) and G2 = (V, E2) be connected graphs on the same vertex set V with more than two vertices. If G1 ∩ G2 = (V, E1 ∩ E2) is not a connected graph, then the graph G1 U G2 = (V, E1 U E2)
 A cannot have a cut vertex B must have a cycle C must have a cut-edge (bridge) D has chromatic number strictly greater than those of G1 and G2
GATE-CS-2004
Discuss it

Question 81 Explanation:

The most intuitive approach should be to try to construct the graph according to the given requirements and then try to eliminate the options.

Refer to the below image for the detailed explanation.   This solution is contributed by Pranjul Ahuja.
 Question 82
Let A[1, ..., n] be an array storing a bit (1 or 0) at each location, and f(m) is a unction whose time complexity is θ(m). Consider the following program fragment written in a C like language:
counter = 0;
for (i = 1; i < = n; i++)
{
if (A[i] == 1)
counter++;
else {
f(counter);
counter = 0;
}
}
The complexity of this program fragment is
 A Ω(n2) B Ω(nlog n) and O(n2) C θ(n) D O(n)
Analysis of Algorithms    GATE-CS-2004
Discuss it

Question 82 Explanation:
Please note that inside the else condition, f() is called first, then counter is set to 0. Consider the following cases:
a) All 1s in A[]: Time taken is Θ(n) as
only counter++ is executed n times.

b) All 0s in A[]: Time taken is Θ(n) as
only f(0) is called n times

c) Half 1s, then half 0s: Time taken is  Θ(n) as
only f(n/2) is called once.
 Question 83
The time complexity of the following C function is (assume n > 0)
int recursive (int n) {
if (n == 1)
return (1);
else
return (recursive (n - 1) + recursive (n - 1));
}

 A O(n) B O(n log n) C O(n2) D O(2n)
GATE-CS-2004
Discuss it

Question 83 Explanation:

See Question 4 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-4/
This solution is contributed by Anil Saikrishna Devarasetty
 Question 84
The recurrence equation
T(1) = 1
T(n) = 2T(n - 1) + n, n ≥ 2 
evaluates to
 A 2n + 1- n - 2 B 2n - n C 2n + 1 - 2n - 2 D 2n - n
Analysis of Algorithms    GATE-CS-2004
Discuss it

Question 84 Explanation:
One way to solve is to use hit and try method.
Given T(n) = 2T(n-1) + n and T(1) = 1

For n = 2, T(2) = 2T(2-1) + 2
= 2T(1) + 2
= 2.1 + 2 = 4

Now when you will put n = 2 in all options,
only 1st option 2^(n+1) - n - 2 satisfies it. 
 Question 85
A program takes as input a balanced binary search tree with n leaf nodes and computes the value of a function g(x) for each node x. If the cost of computing g(x) is min{no. of leaf-nodes in left-subtree of x, no. of leaf-nodes in right-subtree of x} then the worst-case time complexity of the program is
 A Θ(n) B Θ(nLogn) C Θ(n2) D Θ(n2log n)
Balanced Binary Search Trees    GATE-CS-2004
Discuss it

Question 85 Explanation:
The recurrence relation for the recursive function is
T(N) = 2 * T(N/2) + n/2
Where N is the total no. of nodes in the tree.
T(N) = 2 * (2*T(N/2) + n/2) + n/2
= 4 * T(N/2) + 3(n/2)
Solve this till T(1) i.e. till we reach the root.
T(N) = c * T(N / 2^i) + (2*i - 1) * (n/2)
Where i = lg(N)
= lg((2n - 1) / 2)
O(c * T(N / 2^i) + (2*i - 1) * (n/2)) reduces to
O((2*i - 1) * (n/2))
O((2*( lg((2n - 1) / 2)) - 1) * (n/2)) ...sub the value of i.
O(n * ln(n)) 
Source: http://www.nid.iitkgp.ernet.in/DSamanta/courses/IT60101_2/Archives/Assignment-%20IC%20Binary%20Trees%20Solutions.pdf
 Question 86
The following finite state machine accepts all those binary strings in which the number of 1's and 0's are respectively.
 A divisible by 3 and 2 B odd and even C even and odd D divisible by 2 and 3
Regular languages and finite automata    GATE-CS-2004
Discuss it

Question 86 Explanation:

Option (B) is eliminated because string 100 contains odd number of 1s and even number of 0s but is not accepted by the DFA. Option(C) is eliminated because string 011 contains even number of 1s and odd number of 0s but is not accepted by the DFA. Option (D) is eliminated because string 11000 has number of 1s divisible by 2 and number of 0s divisible by 3 but still not accepted by the DFA. Option (A) accepts all strings with number of 1s divisible by 3 and number of 0s divisible by 2.

Extra note: In any case where (no of 1s) MOD N= some integer k and (no of 0s) MOD M= some integer q the number of states in the DFA will be equal to N*M. (The product could be taken for all input alphabets.) E.g.: if we say no. of ones is even and no. of 0s is odd (we check if (no. of 1s) MOD 2=0 and (no. of 0s) MOD 2=0) so no. of states in the DFA=2*2=4. Hence option (B) and (C) can directly be eliminated as the DFA has 6 states and we can look only at the remaining two options.

This solution is contributed by Yashika Arora .

 Question 87
The language {am bn Cm+n | m, n ≥ 1} is
 A regular B context-free but not regular C context sensitive but not context free D type-0 but not context sensitive
Context free languages and Push-down automata    GATE-CS-2004
Discuss it

Question 87 Explanation:

We construct a PDA for the given language.
PUSH Z0 in the stack initially. PUSH X in the stack for each occurrence of ‘a’ . PUSH Y in the stack for each occurrence of ‘b’. POP X and Y from the stack for each occurrence of ‘c’.
If after popping all X and Y from the stack , no input element is left in the string and we get Z0 on the top of the stack then the string is accepted.

Thus, option (B) is correct.

Please comment below if you find anything wrong in the above post.
 Question 88
Consider the following grammar G:
S → bS | aA | b
A → bA | aB
B → bB | aS | a 
Let Na(w) and Nb(w) denote the number of a's and b's in a string w respectively. The language L(G) ⊆ {a, b}+ generated by G is
 A { w | Na(w) > 3Nb(w)} B { w | Nb(w) > 3Nb(w)} C { w | Na(w) = 3k, k ∈ {0, 1, 2, ...}} D { w | Nb(w) = 3k, k ∈ {0, 1, 2, ...}}
GATE-CS-2004
Discuss it

Question 88 Explanation:
Here, we have
S → bS
S → baA	     (S → aA)
S → baaB     (A → aB)
S → baaa     (B → a)

Therefore, | Na (w) | = 3. Also, if we use A → bA instead of A → aB,
S → baA
S → babA

To terminate A, we would have to use A → aB as only B terminates at a (B → a).
S → baA
S → babA
S → babaB
S → babaa

Thus, here also, | Na (w) | = 3.

So, C is the correct choice.

Please comment below if you find anything wrong in the above post.
 Question 89
L1 is a recursively enumerable language over Σ. An algorithm A effectively enumerates its words as w1, w2, w3, ... Define another language L2 over Σ Union {#} as {wi # wj : wi, wj ∈ L1, i < j}. Here # is a new symbol. Consider the following assertions.
S1 :  L1 is recursive implies L2 is recursive
S2 : L2 is recursive implies L1 is recursive 
Which of the following statements is true ?
 A Both S1 and S2 are true B S1 is true but S2 is not necessarily true C S2 is true but S1 is not necessarily true D Neither is necessarily true
Recursively enumerable sets and Turing machines    GATE-CS-2004
Discuss it

 Question 90
Choose the best matching between the programming styles in Group 1 and their characteristics in Group 2.
 Group-1 Group-2 P. Functional 1. Command-based, proce-dural Q. Logic 2. Imperative, abstract data type R. Object-oriented 3. Side-effect free, declarative, expression evaluation S. Imperative 4. Declarative, clausal representation, theorem proving
 A P-2, Q-3, R-4, S-1 B P-4, Q-3, R-2, S-1 C P-3, Q-4, R-1, S-2 D P-3, Q-4, R-2, S-1
Principles of Programming Languages    GATE-CS-2004
Discuss it

Question 90 Explanation:
P: Functional Programming is declarative in nature, involves expression evaluation, & side effect free. Q: Logic is also declarative but involves theorem proving. R: Object oriented is imperative statement based & have abstract (general) data types. S: Imperative: The programs are made giving commands & follows definite procedure & sequence
There are 90 questions to complete.

## GATE CS Corner

See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.