DISCLAIMER: This is a sample exam to show the new structure, and is not an indication of the actual problems that will appear on an exam. The problems are from past exams, with the exception of Automata Theory.
Given 3 Data Structure problems, choose 2 out of 3:
c -> a -> f -> r -> q
Write a non-recursive function, in the language of your choice, which reverses all of the pointers, for example:
c <- a <- f <- r <- q
The function should return a pointer to the last node in the list (and this node is effectively the new head of the list). An initial call would be:
p = reverse(p);
tree_ptr find_parent(char x, tree_ptr p)
Given 2 Operating Systems problems and 1 Architecture problem, choose 2 out of 3:
int p = -1; // GLOBAL variable shared by all processes, initialized once
int lock = 0; // GLOBAL variable shared by all processes, initialized once
while (1) {
while (lock == 1) {} // empty loop body
p = (p+1) % N;
}
Each worker process has its own process ID mypid, and executes the following code:
while (1) {
while (p != mypid) {} // empty loop body
lock = 1;
// CRITICAL SECTION WHERE THE PROCESS DOES WORK
lock = 0;
}
a) Does the solution guarantee mutual exclusion?
b) Does the solution guarantee that work will be done?
c) Does the solution guarantee fairness?
a) Briefly explain the term "page fault".
b) Briefly explain the term "page replacement policy"
c) Briefly explain how the LRU policy works.
d) In demand paged memory management that uses LRU, a process makes the following sequence of page references:
1 3 4 2 1 1 2 3 4 3 5 1 4 6 1 4 3
Calculate the number of page faults, assuming that only 3 page frames are available to the process. Assume that no pages are initially loaded. Show your work.
Given 1 Programming Languages problem, 1 Analysis problem, 1 Theory of Computation problem, choose 2 out of 3:
int i = 2;
int j = 3;
int a[4] = {3, 7, 2, 2};
int f(int &x, int &y) {
int *p;
int *q;
p = &j;
q = p;
a[i] = a[j--];
return (i + j + a[i] + a[j] + *p + *q + x + y);
}
int main() {
cout << f(i,i) << endl;
}
a) Write a routine to construct the shortest path from vertex u to vertex w. Code in the language of your choice. For fundamental local data structures (stack, queues, priority queues, etc.), you may call functions for the basic operations without writing the actual code.
b) State in BIG-THETA terms the worst case runtime of your routine. Your answer should be the best description as a function of n and m. Note the fundamental local data structure implementations if they affect the result. Justify your answer.
Fall 2006: students may elect to choose one problem from Theory of Computation. This problem will be EITHER Complexity OR Automata Theory:
Some other examples for Automata Theory:
Show the state diagram for a PDA that recognizes {0n#1n | n > 0}.
Construct a PDA from the following CFG:
S --> aTb | b
T --> Ta | epsilon
Show that the class of regular languages is closed under the concatenation operator.
Use the Pumping Lemma to show that the language {anbncn | n > 0} is not context-free.
Draw the state diagram for a DFA recognizing the language L = {w | w starts with 1 and |w| is even, or w starts with 0 and contains an even number of 0s}
Convert a NFA into an equivalent DFA.