



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
It covers core computer science topics: Programming Languages and Compilers, Op- erating Systems, and Algorithms. The exam has two parts.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




This is the common examination for the M.S. program in CS. It covers core computer science topics: Languages and Compilers, Op erating Systems, and Algorithms. The exam has two parts. The rst part lasts three hours and covers the rst two topics. The second part, given this afterno on, lasts one and one-half hours, and covers algorithms.
Attempt all of the questions. You are not required to take the algorithms section of the exam if you have passed the FOCS exam in the past.
Use a separate b o oklet for each question. Mark each b o oklet with your exam numb er and with the question it contains. Do not answer more than one question p er b o oklet.
You will b e graded according to your exam numb er, shown on the enve- lop e containing the b o oklets. Rememb er your exam numb er: when grades are given out, they will b e published according to this numb er, not by name.
Make sure your name and signature are on the envelop e. This is the only place where your name app ears. Please include all the b o oklets inside the envelop e. You can keep the exam.
Go o d luck!
Programming Languages and Compilers
a. In a few sentences, explain how inheritance contributes to data ab- straction and co de reuse.
b. What do es the following fragment print?
class A { public: void mf () {cout << "I am an A." << endl; }
class B : public A { public: void mf () { cout << "I am a B" << endl; }
B x; A *pB = &x; B *pA = &x; pB -> mf (); pA -> mf ();
c. Do es the answer to (b) change if metho d mf is declared virtual? ex- plain.
next b o oklet please. Many programming languages have constructs that manipulate slices, that is to say contiguous p ortions of one-dimensional arrays. For example, in Ada slices can b e used wherever array values can b e used, which includes expressions, assignments, and actuals in subprogram calls:
A (x .. y) := B (s .. t); (1) if s (1..3) = (11, 19, 37) then ... (2) Modify (A (x+1 .. y-1)); (3)
a. Write a grammar for expressions that includes slices. You can use the syntax of Ada, or that of any other language you know that supp orts slices. Make sure that slices of slices are legal. Your grammar should include arithmetic op erators and indexed expressions, that is to say array comp onents.
Op erating Systems
next b o oklet please.
a. Nearly all mo dern systems with demand paging use pages of ab out the same size (8KB give or take one or p ossibly two p owers of 2). Since these systems do NOT use huge pages (say > 128KB) or tiny pages (say < 1KB) there must b e problems with very large pages and with very small pages. DESCRIBE these problems.
b. Imagine a technology change in paging disks so that b oth seek time and rotational latency take zero time (i.e. the only delay is the time to transfer the requested page). Would this change argue for larger or smaller pages or would it not e ect the choice of page size? JUSTIFY your answer.
c. Now imagine that disks remain as they are to day but memory prices decrease 100 fold so that p ersonal computers have over a gigabyte (1000MB) of RAM. Would this change argue for larger or smaller pages or would it not e ect the choice of page size? JUSTIFY your answer.
next b o oklet please.
Consider the following preemptive priority-scheduling algorithm based on dynamic priorities. Larger priority numb ers imply higher priority. When a pro cess is waiting for the CPU (on the ready queue, but not running) its priority changes at rate a; when it is running, its priority changes at the rate b. All pro cesses are given a priority of 0 when they enter the ready queue. The parameters a and b can b e set to give many di erent scheduling algorithms.
a. What is the algorithm that results from b > a > 0? Explain.
b. How can this scheme b e mo di ed (choices for a, b, and initial values) to obtain round-robin scheduling?
This is the common examination for the M.S. program in CS. It covers core computer science topics: Languages and Compilers, Op erating Systems, and Algorithms. The exam has two parts. The rst part lasts three hours and covers the rst two topics. The second part, given this afterno on, lasts one and one-half hours, and covers algorithms.
Attempt all of the questions. You are not required to take the algorithms section of the exam if you have passed the FOCS exam in the past.
Use a separate b o oklet for each question. Mark each b o oklet with your exam numb er and with the question it contains. Do not answer more than one question p er b o oklet.
You will b e graded according to your exam numb er, shown on the enve- lop e containing the b o oklets. Rememb er your exam numb er: when grades are given out, they will b e published according to this numb er, not by name.
Make sure your name and signature are on the envelop e. This is the only place where your name app ears. Please include all the b o oklets inside the envelop e. You can keep the exam.
Go o d luck!
Question 3 (next b o oklet, please) Supp ose you are given the problem of nding in sorted order the k smallest integers in an array of size n, where k is much smaller than n but much larger than 1.
a. (5 p oints) Describ e how selection sort, mergesort, heapsort, and quick- sort can b e adapted to this problem. (There is nothing to b e done with insertion sort). Your description need not give the pseudo-co de for the mo di ed algorithms; it is enough to describ e clearly what changes can b e made.
b. (3 p oints) Find the worst-case running time of the mo di ed selection sort.
c. (2 p oints) Show that any comparison-based metho d for solving this problem must take at least time (k log n) in the worst case.