Exams › GATE › Technical › Computer Science and Information Technology (CS1)
22 questions with worked solutions.
Answer: (iii), (i), (ii)
The correct sequence is (iii), (i), (ii) because the processor must first complete the current instruction to ensure data integrity, then save the program counter to remember where to return after handling the interrupt, and finally load the program counter with the ISR's address to begin executing the interrupt service routine.
Q2. Which ONE of the following statements is FALSE regarding the symbol table?
Answer: Symbol table is not required after the parsing phase.
The symbol table is essential during the semantic analysis and code generation phases, as it maintains information about variable types and scopes, making it necessary beyond just parsing.
Answer: Register assignment to variables
Register assignment to variables relies on live variable analysis to determine which variables are actively needed at a given point in the program, allowing the compiler to allocate registers more efficiently and minimize unnecessary memory access.
Answer: 2²¹
Logical address is 32 bits and page size is 2048=2^11 bytes, so the page-number field is 32-11=21 bits. The page table has at most 2^21 entries, not 2^22.
Answer: Both T2 and T3
T1 writes Y then aborts. T2 reads Y (R2(Y)) after W1(Y), a dirty read, so T2 must roll back. T3 also reads Y (R3(Y)) which carries T1's uncommitted value, so T3 must roll back too. Both T2 and T3 are rolled back.
Answer: (a)-(I), (b)-(III), (c)-(II)
The correct option matches the functionalities accurately: the Network layer is responsible for packet routing (I), the Transport layer facilitates host-to-host communication (III), and the Datalink layer handles framing and error detection (II). This alignment reflects the specific roles each layer plays in the OSI model.
Answer: d1(u,v) ≤ d2(u,v)
The shortest path distance in the original graph G, denoted as d1(u,v), can be equal to or less than the distance in the minimum spanning tree T, denoted as d2(u,v), because T may not include all edges of G and thus cannot provide a shorter path than the shortest path available in G.
Answer: L(G) = {a² bⁿ | n ≥ 1} ∪ {aⁿ b² | n ≥ 1}
The correct option describes the language generated by the grammar, where the productions allow for the generation of strings with two 'a's followed by one or more 'b's, or any number of 'a's followed by exactly two 'b's, thus matching the specified patterns.
Answer: (B)
Option (B) is correct because the function X produces a '1' when at least two inputs are '1'. In this case, if a and b are both '1', adding another '1' (from c) does not change the output, confirming that X(a,b,X(a,b,c)) equals X(a,b,c).
Answer: 11111010 in 8-bits
The correct option, 11111010 in 8-bits, accurately represents -6 in 2's complement form, as it is derived by inverting the binary representation of +6 (00000110) and adding 1, resulting in 11111010.
Answer: An inorder traversal will always produce a sorted sequence of elements.
In a binary search tree, the left subtree contains only nodes with values less than the parent node, and the right subtree contains only nodes with values greater than the parent node. Therefore, an inorder traversal, which visits the left subtree, the parent node, and then the right subtree, will always yield the elements in sorted order.
Answer: Every DFA that accepts L has > 2ⁿ states.
This statement is false because while a DFA can have up to 2ⁿ states in the worst case when converting from an NFA with n states, it is not guaranteed that every DFA accepting the same language must exceed that number of states; some DFAs may have fewer states.
Answer: 25
The function 'foo' takes a pointer and an integer, assigning the integer value to the location pointed to by the pointer. Since 'z' points to 'a' and 'foo' sets '*p' (which is 'a') to 'b' (25), the value of 'a' is updated to 25, resulting in the output.
Answer: 6 × 2¹⁰
To determine the number of bits required to store all the tag values in a direct-mapped cache, we first calculate the number of cache lines, which is the cache size divided by the block size. With 16K bytes of cache and a block size of 16 bytes, there are 1024 cache lines. The main memory has 1M bytes, which corresponds to 20 bits for addressing. The index requires 10 bits (since 1024 = 2¹⁰), leaving 10 bits for the tag (20 total bits - 10 index bits). Thus, the total number of bits for all tag values is 1024 lines multiplied by 10 bits, resulting in 6 × 2¹⁰ bits.
Answer: 9.00
At t=0 M1 takes its top-priority P1 (0-20) and M2 takes its top-priority P2 (0-16). At t=16 M2 frees and takes P3 (16-41); at t=20 M1 frees and takes P4 (20-30). Waiting times are P1=0, P2=0, P3=16, P4=20, average = 36/4 = 9.00 ms.
Answer: { p.pname | p ∈ players ∧ ∃t (t ∈ teams ∧ p.tid = t.tid ∧ t.tname = 'MI') }
This option correctly identifies players from the 'players' relation and checks for the existence of a corresponding team in the 'teams' relation that matches the specified team name 'MI', ensuring that only players from that team are selected.
Answer: The height of T is at least 15.
The height of the breadth-first search tree T must be at least 15 because the maximum distance between any two vertices in the graph is 30, and in a BFS tree, the height represents the longest path from the root to any leaf. Since the maximum distance is 30, the tree must span at least half of that distance to connect vertices, ensuring a minimum height of 15.
Answer: Both L1 and L2 are context-free languages.
Both L1 and L2 can be generated by context-free grammars, as they can be expressed with rules that allow for the balanced counting of 'a's and 'b's while accommodating the unrestricted number of 'c's, which can be derived from the context-free language properties.
Answer: If there is any input right end marker, it will be added to Follow(S), where S is the start symbol.
The correct option is true because the Follow set of a non-terminal includes the end-of-input marker to indicate that the parsing can successfully complete when reaching the start symbol, allowing the parser to recognize the end of the input.
Answer: ∀x∃y[mother(y,x) ∧ ¬∃z(noteq(z,y) ∧ mother(z,x))]
The correct option accurately captures the idea that for every individual x, there exists a unique mother y such that no other individual z can also be a mother of x, ensuring that y is the only mother.
Answer: 0.9509900499
Each bit is correct with probability 0.99 and bits are independent, so the message is error-free with probability 0.99^5 = 0.95099. The stored answer 0.96059601 is 0.99^4 (only 4 bits) and is wrong; the correct value is option 0.
Answer: The value printed by the given C program is ________ (An answer in integer)
The function 'gate' processes the digits of the input number by alternating between skipping and including digits, effectively reversing the order of every second digit starting from the least significant one. For the input 14362, it retains the digits 4, 3, and 2, resulting in the output 42.