Jin Hyun Park / Qual Exam Prep / Sample questions
Questions in the style of the exam. Each one comes with the answer and, more importantly, the reason.
Answer: (4) Selection sort.
Selection sort finds the smallest remaining element and swaps it into place, so it makes at most n − 1 swaps in total. The other three can swap far more often (insertion sort, for example, shifts elements one position at a time).
Answer: 60 ns.
On a hit (80% of the time) the cost is 30 ns. On a miss (20%) you pay for the cache lookup and the memory access, 30 + 150 = 180 ns. So the average is 0.8 × 30 + 0.2 × 180 = 24 + 36 = 60 ns.
Answer: 3.
By De Morgan's law, A + B = ¬(¬A · ¬B). You need one NAND to make ¬A (tie both inputs to A), one to make ¬B, and one NAND of those two results.
Answer: because the potential for concurrent activity among system resources increases.
With more processes in memory, while one waits for I/O another can use the CPU, so the hardware sits idle less often.
Answer: because some system resource begins to saturate, i.e. reaches 100% utilization.
Once the CPU (or the disk, or memory) is already busy all the time, adding more processes cannot add more work per second.
Answer: only I.
A subset of a finite set is finite, so I holds. But II and III fail: Σ* is regular, and every language is a subset of Σ*, including non-regular and non-context-free ones. Being a subset says nothing about the complexity of the language.
Answer: only I.
I: in a pipeline, one instruction finishes per clock cycle at best, so throughput is set by the clock cycle alone, and 7.5 ns is shorter than 10 ns. II: latency is (number of stages) × (cycle time): 5 × 10 = 50 ns on M-5 versus 7 × 7.5 = 52.5 ns on M-7, so M-7 is actually slower per instruction. III: a deeper pipeline suffers more from hazards and branch mispredictions, so "always" is false.
Answer: a resource allocation graph.
Processes and resources are nodes; requests and assignments are edges. A cycle in the graph is a necessary condition for deadlock (and a sufficient one if each resource has a single instance).
Answer: only I.
The whole point of virtual memory is that a process can address more than what physically fits (I), because pages can live on disk and be brought in on demand (so II is false). Pages are fixed-size chunks that ignore program structure; it is segments that follow the program's logical units (so III is false).
Answer: (1).
In a snoopy cache, each cache controller watches ("snoops on") the shared bus and reacts when another processor writes to an address it holds a copy of. Done properly, this keeps caches coherent without slowing down the normal operation of the processor.
Answer: only I.
More buffers let producers and consumers get further out of step with each other, which improves throughput. The buffer count does not change the logic of the program, so neither deadlock behavior nor correctness is affected.
lw) instruction cause?
Answer: up to 2 per memory reference, so up to 4 for the whole instruction (with a single-level page table).
To translate any address you first need the page table. In the worst case the page-table page itself is on disk: one page fault. Then the page holding the target may also be on disk: a second page fault. An lw makes two memory references, the instruction fetch and the data load, so it can fault twice in the fetch phase and twice again in the execute phase. Read the question carefully: some versions ask per phase (answer 2), others per instruction (answer 4).
Answer: it is infinite, but it may be decidable or undecidable.
Every undecidable language is infinite (a finite language is always decidable, since you can list its members), so the union is infinite. Whether the union is decidable depends on the particular languages: for example, if L1 = Σ*, the union is Σ*, which is decidable.
Answer: P1 can be solved in polynomial time (BFS or Dijkstra), but P2 is NP-complete and is not known to be solvable in polynomial time.
The one exception worth remembering: on a directed acyclic graph, the longest path can be found in linear time by processing the vertices in topological order.
Answer: I and III.
A copying collector starts from the roots and copies every reachable object to the other half of the heap. A cycle of dead objects is unreachable, so it is simply never copied (I). The copied objects end up packed together, so there is no fragmentation (III). Nothing happens on assignment; that is the cost of reference counting, not of copying collection (II is false).
Answer: (2).
The shortest cycle (the girth) can be found with a BFS from each vertex. Longest cycle, maximum clique, and minimum coloring are all NP-hard. Listing all spanning trees is not hard per tree, but a graph can have exponentially many of them, so the output alone can be exponential in size.
Overview · Useful materials · Algorithms · Architecture · OS · Networking · Databases · Automata · AI / ML · Things to remember