GATE 2014 (Session 3)
65 questions
MCQ 47 · NAT 181-mark 30 · 2-mark 35
Questions 26–30 of 65
Let be a finite non-empty alphabet and let be the power set of . Which one of the following is TRUE?
Answer: (C)
We can write the strings of in a list, first by length and then in dictionary order. So it is countably infinite.
Now is the power set of a countably infinite set. By Cantor's theorem, it is uncountable.
Answer: is uncountable and is countable
Now is the power set of a countably infinite set. By Cantor's theorem, it is uncountable.
Answer: is uncountable and is countable
One of the purposes of using intermediate code in compilers is to
Answer: (C)
Intermediate code does not depend on the machine. So the same optimizer (and front end) can be used again with other back ends for other machines.
Answer: increase the chances of reusing the machine-independent code optimizer in other compilers
Answer: increase the chances of reusing the machine-independent code optimizer in other compilers
Which of the following statements are CORRECT?
1) Static allocation of all data areas by a compiler makes it impossible to implement recursion.
2) Automatic garbage collection is essential to implement recursion.
3) Dynamic allocation of activation records is essential to implement recursion.
4) Both heap and stack are essential to implement recursion.
1) Static allocation of all data areas by a compiler makes it impossible to implement recursion.
2) Automatic garbage collection is essential to implement recursion.
3) Dynamic allocation of activation records is essential to implement recursion.
4) Both heap and stack are essential to implement recursion.
Answer: (D)
Let us go through the statements one by one:
- 1: In static allocation, every function gets only one fixed data area. A recursive call would write over it This is True.
- 2: Recursion does not need garbage collection This is False.
- 3: Every call must have its own activation record, made at run time This is True.
- 4: A stack is enough, and a heap is not required This is False.
Answer: 1 and 3 only
- 1: In static allocation, every function gets only one fixed data area. A recursive call would write over it This is True.
- 2: Recursion does not need garbage collection This is False.
- 3: Every call must have its own activation record, made at run time This is True.
- 4: A stack is enough, and a heap is not required This is False.
Answer: 1 and 3 only
In the context of modular software design, which one of the following combinations is desirable?
Answer: (B)
Cohesion measures how closely the parts inside one module belong together. Coupling measures how much modules depend on each other.
A good modular design has high cohesion (each module does one clear job) and low coupling (modules can be changed, tested and reused on their own).
Answer: (B)
A good modular design has high cohesion (each module does one clear job) and low coupling (modules can be changed, tested and reused on their own).
Answer: (B)
A system uses 3 page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy. Assume that all the page frames are initially empty. What is the total number of page faults that will occur while processing the page reference string given below? 4, 7, 6, 1, 7, 6, 1, 2, 7, 2
Answer: 6
LRU with 3 frames:
- 4, 7, 6: all faults (3)
- 1: fault, 4 is removed {7, 6, 1} (4)
- 7, 6, 1: all hits
- 2: fault, LRU page 7 is removed {6, 1, 2} (5)
- 7: fault, 6 is removed {1, 2, 7} (6)
- 2: hit
Answer: 6
- 4, 7, 6: all faults (3)
- 1: fault, 4 is removed {7, 6, 1} (4)
- 7, 6, 1: all hits
- 2: fault, LRU page 7 is removed {6, 1, 2} (5)
- 7: fault, 6 is removed {1, 2, 7} (6)
- 2: hit
Answer: 6