Question 1 |

have well indented programs | |

be able to infer the flow of control from the compiled code | |

be able to infer the flow of control from the program text | |

avoid the use of GOTO statements |

**Principles of Programming Languages**

**GATE-CS-2004**

**Discuss it**

Question 2 |

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.

Call swap (x, y) | |

Call swap (&x, &y) | |

swap(x,y) cannot be used as it does not return any value | |

swap(x,y) cannot be used as the parameters are passed by value |

**Functions**

**GATE-CS-2004**

**Discuss it**

Question 3 |

(top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1) | |

top1 + top2 = MAXSIZE | |

(top1= MAXSIZE/2) or (top2 = MAXSIZE) | |

top1= top2 -1 |

**GATE-CS-2004**

**Discuss it**

Question 4 |

2 | |

3 | |

4 | |

6 |

**GATE-CS-2004**

**Discuss it**

Question 5 |

queue | |

stack | |

tree | |

list |

**GATE-CS-2004**

**Discuss it**

Question 6 |

preorder traversal | |

inorder traversal | |

depth first search | |

breadth first search |

**Tree Traversals**

**GATE-CS-2004**

**Discuss it**

Question 7 |

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

1 only | |

2 only | |

1 and 2 only | |

3 or 4 |

**GATE-CS-2004**

**Discuss it**

Question 8 |

1. P → Q R 2. P → Q s R 3. P → ε 4. P → Q t R r

1 only | |

1 and 3 only | |

2 and 3 only | |

3 and 4 only |

**Parsing and Syntax directed translation**

**GATE-CS-2004**

**Discuss it**

Question 9 |

Edit-time | |

Compile-time | |

Link-time | |

Load-time |

**Misc**

**GATE-CS-2004**

**Discuss it**

**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 |

E1 should be evaluated first | |

E2 should be evaluated first | |

Evaluation of E1 and E2 should necessarily be interleaved | |

Order of evaluation of E1 and E2 is of no consequence |

**Code Generation and Optimization**

**GATE-CS-2004**

**Discuss it**

**Vineet Purswani**.

Question 11 |

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 kernelWhich of the above statements are true?

(ii), (iii) and (iv) only | |

(ii) and (iii) only | |

(i) and (iii) only | |

(i) and (ii) only |

**GATE-CS-2004**

**Discuss it**

User level thread |
Kernel level thread |
---|---|

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. |

Example : Java thread, POSIX threads. | Example : Window Solaris. |

Question 12 |

50% | |

40% | |

25% | |

0% |

**Input Output Systems**

**GATE-CS-2004**

**Discuss it**

Question 13 |

1 | |

2 | |

3 | |

4 |

**Database Design(Normal Forms)**

**GATE-CS-2004**

**Discuss it**

Question 14 |

Student (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 ?rollno, name, address) Enroll (rollno, courseno, coursename)

8, 0 | |

120, 8 | |

960, 8 | |

960, 120 |

**SQL**

**GATE-CS-2004**

**Discuss it**

**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 ------------------------------------- Rollno name Address ------------------------------------- 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 ---------------------------------------------- Rollno Name Address Courseno Coursename ---------------------------------------------- 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 |

Group-1 Group-2 P. Data link 1. Ensures reliable transport of data over a physical point-to-point link 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

P-1, Q-4, R-3 | |

P-2, Q-4, R-1 | |

P-2, Q-3, R-1 | |

P-1, Q-3, R-2 |

**Misc Topics in Computer Networks**

**GATE-CS-2004**

**Discuss it**

Question 16 |

Both bridge and router selectively forward data packets | |

A bridge uses IP addresses while a router uses MAC addresses | |

A bridge builds up its routing table by inspecting incoming packets | |

A router can connect between a LAN and a WAN |

**Misc Topics in Computer Networks**

**GATE-CS-2004**

**Discuss it**

Question 17 |

x' + y' | |

x + y | |

x + y' | |

x' + y |

**Digital Logic & Number representation**

**GATE-CS-2004**

**Discuss it**

Question 18 |

Q = 0, Q' = 1 | |

Q = 1, Q' = 0 | |

Q = 1, Q' = 1 | |

Indeterminate states |

**Digital Logic & Number representation**

**GATE-CS-2004**

**Discuss it**

**RACE CONDITION”**occurs and output become unstable. So ans is (D) part.

Question 19 |

_{x}(in base-x number system) is equal to 54

_{y}(in base-y number system), the possible values of x and y are

8, 16 | |

10, 12 | |

9, 13 | |

8, 11 |

**GATE-CS-2004**

**Number Representation**

**Discuss it**

Question 20 |

(i) Absolute addressing (ii) Based addressing (iii) Relative addressing (iv) Indirect addressing

(i) and (iv) | |

(i) and (ii) | |

(ii) and (iii) | |

(i), (ii) and (iv) |

**GATE-CS-2004**

**Microprocessor**

**Discuss it**

**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 instruction set architecture | |

page size | |

physical memory size | |

number of processes in memory |

**Memory Management**

**GATE-CS-2004**

**Discuss it**

**Nitika Bansal**

Question 22 |

600 | |

800 | |

876 | |

1200 |

**Data Link Layer**

**GATE-CS-2004**

**Discuss it**

"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 |

"Some boys in the class are taller than all the girls"Note : taller(x,y) is true if x is taller than y.

(∃x) (boy(x) → (∀y) (girl(y) ∧ taller(x,y))) | |

(∃x) (boy(x) ∧ (∀y) (girl(y) ∧ taller(x,y))) | |

(∃x) (boy(x) → (∀y) (girl(y) → taller(x,y))) | |

(∃x) (boy(x) ∧ (∀y) (girl(y) → taller(x,y))) |

**Propositional and First Order Logic.**

**GATE-CS-2004**

**Discuss it**

Question 24 |

S = {(x, y) | y = x+1 and x, y ∈ {0, 1, 2, ...}}The reflexive transitive closure of S is

{(x, y) | y > x and x, y ∈ {0, 1, 2, ... }} | |

{(x, y) | y ≥ x and x, y ∈ {0, 1, 2, ... }} | |

{(x, y) | y < x and x, y ∈ {0, 1, 2, ... }} | |

{(x, y) | y ≤ x and x, y ∈ {0, 1, 2, ... }} |

**Set Theory & Algebra**

**GATE-CS-2004**

**Discuss it**

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 |

3/8 | |

1/2 | |

5/8 | |

2/4 |

**Probability**

**GATE-CS-2004**

**Discuss it**

Question 26 |

^{x})

power(2, n) | |

power(2, n ^{2}) | |

power(2, (n ^{2} + n)/2) | |

power(2, (n ^{2} - n)/2) |

**Combinatorics**

**GATE-CS-2004**

**Discuss it**

**Mohit Gupta.**

Question 27 |

^{-1}is

D ^{-1}C^{-1}A^{-1} | |

CDA | |

ADC | |

Does not necessarily exist |

**Linear Algebra**

**GATE-CS-2004**

**Discuss it**

Question 28 |

(113. + -111.) + 7.51 113. + (-111. + 7.51)

9.51 and 10.0 respectively | |

10.0 and 9.51 respectively | |

9.51 and 9.51 respectively | |

10.0 and 10.0 respectively |

**GATE-CS-2004**

**Number Representation**

**Discuss it**

(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 |

n | |

n ^{2} | |

n log n | |

n log ^{2} n |

**GATE-CS-2004**

**Discuss it**

Question 30 |

both in P | |

both NP-complete | |

NP-complete and in P respectively | |

undecidable and NP-complete respectively |

**GATE-CS-2004**

**Discuss it**

Question 31 |

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

5 | |

6 | |

7 | |

8 |

**Recursion**

**GATE-CS-2004**

**Discuss it**

Question 32 |

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:

n = D1D2….Dm-i and rev = DmDm-1…Dm-i+1 | |

n = Dm-i+1…Dm-1Dm and rev = Dm-1….D2D1 | |

n != rev | |

n = D1D2….Dm and rev = DmDm-1…D2D1 |

**Misc**

**GATE-CS-2004**

**Discuss it**

Question 33 |

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)

gnirts | |

gnirt | |

string | |

no output is printed |

**GATE-CS-2004**

**Discuss it**

Question 34 |

(i), (iv), (vi), (viii) | |

(i), (iv), (vii) | |

(i), (iii), (v), (vi), (viii) | |

(ii), (v), (viii) |

**OOP Concepts**

**GATE-CS-2004**

**Discuss it**

Question 35 |

(i) preorder and postorder (ii) inorder and postorder (iii) preorder and inorder (iv) level order and postorder

(i) only | |

(ii), (iii) | |

(iii) only | |

(iv) only |

**Tree Traversals**

**GATE-CS-2004**

**Discuss it**

**Anil Saikrishna Devarasetty**

Question 36 |

rear node | |

front node | |

not possible with a single pointer | |

node next to front |

**GATE-CS-2004**

**Discuss it**

Question 37 |

a | |

b | |

c | |

d |

**GATE-CS-2004**

**Discuss it**

32 / \ 15 20 / \ / \ 30 12 25 16Now, we need to swap 15 with 30 and 20 with 25.

32 / \ 30 25 / \ / \ 15 12 20 16This 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 |

abc × + def ^ ^ - | |

abc × + de ^ f ^ - | |

ab + c × d - e ^ f ^ | |

- + a × bc ^ ^ def |

**Stack**

**GATE-CS-2004**

**Discuss it**

**parul Sharma.**

Question 39 |

best if A is in row-major, and B is in column- major order | |

best if both are in row-major order | |

best if both are in column-major order | |

independent of the storage scheme |

**Analysis of Algorithms**

**GATE-CS-2004**

**Discuss it**

Question 40 |

union only | |

intersection, membership | |

membership, cardinality | |

union, intersection |

**GATE-CS-2004**

**Discuss it**

Question 41 |

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

x ÷ y using repeated subtraction | |

x mod y using repeated subtraction | |

the greatest common divisor of x and y | |

the least common multiple of x and y |

**Misc**

**GATE-CS-2004**

**Discuss it**

Question 42 |

x = m; y = 1; while (x - y > e) { x = (x + y)/2; y = m/x; } print(x);(Assume m > 1, e > 0).

log m | |

m ^{2} | |

m ^{1/2} | |

m ^{1/3} |

**Misc**

**GATE-CS-2004**

**Discuss it**

Question 43 |

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 |

**GATE-CS-2004**

**Discuss it**

**Parul Sharma.**

Question 44 |

P, Q, R, S, T, U | |

P, Q, R, U, S, T | |

P, Q, R, U, T, S | |

P, Q, T, R, U, S |

**GATE-CS-2004**

**Discuss it**

Question 45 |

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 |

**Parsing and Syntax directed translation**

**GATE-CS-2004**

**Discuss it**

Question 46 |

Process Arrival Time Burst Time P1 0 5 P2 1 3 P3 2 3 P4 4 1What 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 |

**GATE-CS-2004**

**CPU Scheduling**

**Discuss it**

P1 | P2 | P4 | P3 | P1 |

1 | 4 | 5 | 8 | 12 |

Question 47 |

645 nanoseconds | |

1050 nanoseconds | |

1215 nanoseconds | |

1230 nanoseconds |

**Memory Management**

**GATE-CS-2004**

**Discuss it**

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/10^{4} )(M EM ) + (1/10^{4}) ∗ 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/10^{4} )(30ns) + (1/10^{4} ) ∗ 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 |

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) |

**Process Management**

**GATE-CS-2004**

**Discuss it**

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.Please read the following to learn more about process synchronization and semaphores: Process Synchronization Set 1 This explanation has been contributed by

**Dheerendra Singh.**

Question 49 |

2 ^{24} bytes | |

2 ^{32} bytes | |

2 ^{34} bytes | |

2 ^{48} bytes |

**Input Output Systems**

**GATE-CS-2004**

**Discuss it**

Size of Disk Block = 1Kbyte Disk Blocks address = 32bits, 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 + 2^{8}+ 2^{8}*2^{8}+ 2^{8}*2^{8}*2^{8}≈ 2^{24}Blocks Since each block is of size 2^{10}Maximum files size = 2^{24}* 2^{10}= 2^{34}

Question 50 |

name, courseNo → grade rollNo, courseNo → grade name → rollNo rollNo → nameThe highest normal form of this relation scheme is

2 NF | |

3 NF | |

BCNF | |

4NF |

**Database Design(Normal Forms)**

**GATE-CS-2004**

**Discuss it**

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 |

__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)"

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 |

**Database Design(Normal Forms)**

**GATE-CS-2004**

**Discuss it**

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 (rThe 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_{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.

**Yashika Arora.**

Question 52 |

24 | |

25 | |

26 | |

27 |

**B and B+ Trees**

**GATE-CS-2004**

**Discuss it**

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 |

Employee (Consider the following SQL queryname, sex, salary, deptName)

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

the average salary is more than the average salary in the company | |

the average salary of male employees is more than the average salary of all male employees in the company | |

the average salary of male employees is more than the average salary of employees in the same department
| |

the average salary of male employees is more than the average salary in the company |

**SQL**

**GATE-CS-2004**

**Discuss it**

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 |

0.5 | |

0.625 | |

0.75 | |

1.0 |

**Data Link Layer**

**GATE-CS-2004**

**Discuss it**

Question 55 |

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 Eth2On which interfaces will the router forward packets addressed to destinations 128.75.43.16 and 192.12.17.10 respectively?

Eth1 and Eth2 | |

Eth0 and Eth2 | |

Eth0 and Eth3 | |

Eth1 and Eth3 |

**Network Layer**

**GATE-CS-2004**

**Discuss it**

Question 56 |

200 | |

220 | |

240 | |

260 |

**Network Layer**

**GATE-CS-2004**

**Discuss it**

Question 57 |

325.5 Kbps | |

354.5 Kbps | |

409.6 Kbps | |

512.0 Kbps |

**Network Layer**

**GATE-CS-2004**

**Discuss it**

Question 58 |

2 | |

3 | |

4 | |

5 |

**Digital Logic & Number representation**

**GATE-CS-2004**

**Discuss it**

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 |

- A+B(C+D)

Question 59 |

a'c and ac' | |

a'c and b'c | |

a'c only | |

ac' and bc' |

**Digital Logic & Number representation**

**GATE-CS-2004**

**Discuss it**

**a'c and ac'**are essential prime implicants.

Question 60 |

R to X, 1 to Y, T to Z | |

T to X, R to Y, T to Z | |

T to X, R to Y, 0 to Z | |

R to X, 0 to Y, T to Z |

**Digital Logic & Number representation**

**GATE-CS-2004**

**Discuss it**

**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)

Question 61 |

Q2' | |

Q2 + Q1 | |

(Q1 ⊕ Q2)' | |

Q1 ⊕ Q2 |

**Digital Logic & Number representation**

**GATE-CS-2004**

**Discuss it**

**Q1Q2’+Q1’Q2**SATISFYING 1 AND 2. SO ANS IS (D) PART.

Question 62 |

4 time units | |

6 time units | |

10 time units | |

12 time units |

**Digital Logic & Number representation**

**GATE-CS-2004**

**Discuss it**

Question 63 |

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 1Consider 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

1007 | |

1020 | |

1024 | |

1028 |

**GATE-CS-2004**

**Microprocessor**

**Discuss it**

Question 64 |

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 1Let 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

29 | |

24 | |

23 | |

20 |

**GATE-CS-2004**

**Microprocessor**

**Discuss it**

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 |

**(B)**

Question 65 |

2 | |

3 | |

4 | |

5 |

**GATE-CS-2004**

**Discuss it**

8, 12, 0, 12, 8 Miss 8 Miss 12 Miss 0 No miss for 12 No miss for 8

Question 66 |

10, 3, 1024 | |

8, 5, 256 | |

5, 8, 2048 | |

10, 3, 512 |

**GATE-CS-2004**

**Microprocessor**

**Discuss it**

^{10}memory size So X,Y size=10,3 So (A) is correct option.

Question 67 |

5.0% | |

1.0% | |

0.5% | |

0.1% |

**Input Output Systems**

**GATE-CS-2004**

**Discuss it**

^{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 |

1100 0100 | |

1001 1100 | |

1010 0101 | |

1101 0101 |

**GATE-CS-2004**

**Number Representation**

**Discuss it**

_{10}(A is a 2's complement number) B = 0000 1010 = 10

_{10}(B is a 2's complement number) A x B = - 60

_{10}= 1 011 1100

_{2}= 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 |

120.4 microseconds | |

160.5 microseconds | |

165.5 microseconds | |

590.0 microseconds |

**Computer Organization and Architecture**

**GATE-CS-2004**

**Discuss it**

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 |

satisfiable but not valid | |

valid | |

a contradiction | |

none of the above |

**Propositional and First Order Logic.**

**GATE-CS-2004**

**Discuss it**

Question 71 |

-x + 5y = -1 x - y = 2 x + 3y = 3

infinitely many | |

two distinct solutions | |

unique | |

none of these |

**Linear Algebra**

**GATE-CS-2004**

**Discuss it**

Question 72 |

* | e | a | b | c |

e | e | a | b | c |

a | a | b | c | e |

b | ||||

c |

c a e b
| |

c b a e | |

c b e a | |

c e a b |

**Set Theory & Algebra**

**GATE-CS-2004**

**Discuss it**

Question 73 |

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 ?

{1} | |

{1}, {2, 3} | |

{1}, {1, 3} | |

{1}, {1, 3}, (1, 2, 3, 4}, {1, 2, 3, 5) |

**Set Theory & Algebra**

**GATE-CS-2004**

**Discuss it**

- 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 |

0 | |

2550 | |

7525 | |

9375 |

**Probability**

**GATE-CS-2004**

**Discuss it**

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 |

9 | |

8 | |

7 | |

6 |

**Combinatorics**

**GATE-CS-2004**

**Discuss it**

**(C) is correct.**Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2004.html

Question 76 |

≤ a + b | |

≤ max {a, b} | |

≤ min {M-a, N-b} | |

≤ min {a, b} |

**Linear Algebra**

**GATE-CS-2004**

**Discuss it**

**(D)**is correct. Source: http://www.cse.iitd.ac.in/~mittal/gate/gate_math_2004.html

Question 77 |

2 | |

3 | |

4 | |

5 |

**Graph Theory**

**GATE-CS-2004**

**Discuss it**

Please comment below if you find anything wrong in the above post.

Question 78 |

nCd /2 ^{n} | |

nCd / ^{d} | |

d/2 ^{n} | |

1/2 ^{d} |

**Probability**

**GATE-CS-2004**

**Discuss it**

^{n}

Question 79 |

A | |

B | |

C | |

D |

**Set Theory & Algebra**

**GATE-CS-2004**

**Discuss it**

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 = (n^{2} – 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, (n^{2} – 3n)/2) ways.

Since minimum no. of edges to be selected for a graph are (n^{2} – 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 - (n^{2} – 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 |

^{2}is

2/3 | |

1 | |

4/3 | |

5/3 |

**Probability**

**GATE-CS-2004**

**Discuss it**

Question 81 |

cannot have a cut vertex | |

must have a cycle | |

must have a cut-edge (bridge) | |

has chromatic number strictly greater than those of G1 and G2 |

**GATE-CS-2004**

**Discuss it**

Question 82 |

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

Ω(n ^{2}) | |

Ω(nlog n) and O(n ^{2}) | |

θ(n) | |

O(n) |

**Analysis of Algorithms**

**GATE-CS-2004**

**Discuss it**

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 |

int recursive (int n) { if (n == 1) return (1); else return (recursive (n - 1) + recursive (n - 1)); }

O(n) | |

O(n log n) | |

O(n ^{2}) | |

O(2 ^{n}) |

**GATE-CS-2004**

**Discuss it**

See Question 4 of http://www.geeksforgeeks.org/data-structures-and-algorithms-set-4/

This solution is contributed by

**Anil Saikrishna Devarasetty**

Question 84 |

T(1) = 1 T(n) = 2T(n - 1) + n, n ≥ 2evaluates to

2 ^{n + 1}- n - 2 | |

2 ^{n} - n | |

2 ^{n + 1} - 2n - 2 | |

2 ^{n} - n |

**Analysis of Algorithms**

**GATE-CS-2004**

**Discuss it**

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 |

Θ(n) | |

Θ(nLogn) | |

Θ(n ^{2}) | |

Θ(n ^{2}log n) |

**Balanced Binary Search Trees**

**GATE-CS-2004**

**Discuss it**

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 |

divisible by 3 and 2 | |

odd and even | |

even and odd | |

divisible by 2 and 3 |

**Regular languages and finite automata**

**GATE-CS-2004**

**Discuss it**

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 |

^{m}b

^{n}C

^{m+n}| m, n ≥ 1} is

regular | |

context-free but not regular | |

context sensitive but not context free | |

type-0 but not context sensitive |

**Context free languages and Push-down automata**

**GATE-CS-2004**

**Discuss it**

We construct a PDA for the given language.

PUSH Z

_{0}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 Z

_{0}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 |

S → bS | aA | b A → bA | aB B → bB | aS | aLet 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

{ w | Na(w) > 3Nb(w)} | |

{ w | Nb(w) > 3Nb(w)} | |

{ w | Na(w) = 3k, k ∈ {0, 1, 2, ...}} | |

{ w | Nb(w) = 3k, k ∈ {0, 1, 2, ...}} |

**GATE-CS-2004**

**Discuss it**

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 → babATo terminate A, we would have to use A → aB as only B terminates at a (B → a).

S → baA S → babA S → babaB S → babaaThus, 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 |

S1 : L1 is recursive implies L2 is recursive S2 : L2 is recursive implies L1 is recursiveWhich of the following statements is true ?

Both S1 and S2 are true | |

S1 is true but S2 is not necessarily true | |

S2 is true but S1 is not necessarily true | |

Neither is necessarily true |

**Recursively enumerable sets and Turing machines**

**GATE-CS-2004**

**Discuss it**

Question 90 |

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 |

P-2, Q-3, R-4, S-1 | |

P-4, Q-3, R-2, S-1 | |

P-3, Q-4, R-1, S-2 | |

P-3, Q-4, R-2, S-1 |

**Principles of Programming Languages**

**GATE-CS-2004**

**Discuss it**