GATE Computer ScienceVery hardGATE CS
A heap holds objects A to J. Roots point to A and E. Pointers: A→B, B→C, B→D, C→B, D→F, E→F, E→I, G→H, H→G, H→J. The root pointer to A is now removed. Reference counting (cascading decrements, no cycle detection) reclaims x objects at that moment, and a complete tracing (mark-sweep) collection run right afterwards would reclaim y objects in total, including any garbage that existed before. What is (x, y)?
- A. (4, 7)
- B. (1, 4)
- C. (1, 7)
- D. (1, 6)
Correct answer: C. (1, 7)
Removing the root count frees A, which decrements B from 2 to 1 (C still points to it), so the B–C cycle and D survive: x = 1. Tracing from the only root E marks E, F and I; everything else is unreachable: A, B, C, D, and the earlier garbage G, H, J, so y = 7.
More Compiler Design questions
- The live ranges (inclusive of both end points, in instruction numbers) of ten variables are [1,8], [2,5], [3,9], [4,6], [7,12], [10,14]…
- Linear-scan register allocation processes the same ten live ranges [1,8], [2,5], [3,9], [4,6], [7,12], [10,14], [11,13], [6,10], [9,15]…
- A syntax-directed translation scheme prints as it reduces: E → T + E { print('+') } | T; T → F T { print('') } | F; F → id {…
- A lexical rule recognises the language (ab | abc | c)(bc | a) over {a, b, c}. How many states does the minimal complete DFA (dead state…
- For the statement a = b (−c) + b (−c), common subexpressions are shared (so −c and b (−c) are each computed once) and the code is stored…
- Grammar: E → E + T | T; T → T F | F; F → ( E ) | id. An SLR(1) parser parses id + id ( id + id ) id. Counting every shift, every reduce…