COMPUTER SCIENCE TRIPOS

Similar documents
COMPUTER SCIENCE TRIPOS Part II (General) DIPLOMA IN COMPUTER SCIENCE

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS Part II (General) DIPLOMA IN COMPUTER SCIENCE

COMPUTER SCIENCE TRIPOS Part II (General) DIPLOMA IN COMPUTER SCIENCE

Notes on the Exam. Question 1. Today. Comp 104:Operating Systems Concepts 11/05/2015. Revision Lectures (separate questions and answers)

Comp 204: Computer Systems and Their Implementation. Lecture 25a: Revision Lectures (separate questions and answers)

COMPUTER SCIENCE TRIPOS Part II (General) DIPLOMA IN COMPUTER SCIENCE

Concurrent & Distributed Systems Supervision Exercises

COMPUTER SCIENCE TRIPOS

Question 1. Notes on the Exam. Today. Comp 104: Operating Systems Concepts 11/05/2015. Revision Lectures

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS

CpSc 421 Final Solutions

COMPUTER SCIENCE TRIPOS

IT 540 Operating Systems ECE519 Advanced Operating Systems

1. [5 points each] True or False. If the question is currently open, write O or Open.

COMPUTER SCIENCE TRIPOS

4. Inputting data or messages to a function is called passing data to the function.

CSCI 270: Introduction to Algorithms and Theory of Computing Fall 2017 Prof: Leonard Adleman Scribe: Joseph Bebel

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

CHAPTER 7. Copyright Cengage Learning. All rights reserved.

Course notes for Data Compression - 2 Kolmogorov complexity Fall 2005

CS 164 Handout 11. Midterm Examination. There are seven questions on the exam, each worth between 10 and 20 points.

Concurrency: a crash course

CS164: Midterm I. Fall 2003

COMPUTER SCIENCE TRIPOS

Introduction to Computer Science. Homework 1

CSE 5317 Midterm Examination 4 March Solutions

Chapter 5 Concurrency: Mutual Exclusion and Synchronization

COMPUTER SCIENCE TRIPOS

Final Examination May 5, 2005

CS 125 Section #4 RAMs and TMs 9/27/16

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

COMPUTER SCIENCE TRIPOS

CSE 401 Midterm Exam Sample Solution 2/11/15

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Friday 20th May 2016 Time: 14:00-16:00

Regular Expressions. Agenda for Today. Grammar for a Tiny Language. Programming Language Specifications

Chapter 5 Concurrency: Mutual Exclusion. and. Synchronization. Operating Systems: Internals. and. Design Principles

Gujarat Technological University Sankalchand Patel College of Engineering, Visnagar B.E. Semester VII (CE) July-Nov Compiler Design (170701)

COMPUTER SCIENCE TRIPOS

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

COMPUTER SCIENCE TRIPOS

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

CS 2210 Sample Midterm. 1. Determine if each of the following claims is true (T) or false (F).

Material from Recitation 1

Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.

14.1 Encoding for different models of computation

CSE P 501 Compilers. LR Parsing Hal Perkins Spring UW CSE P 501 Spring 2018 D-1

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

What Every Programmer Should Know About Floating-Point Arithmetic

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Topic 7 Machine learning

Compiler phases. Non-tokens

CS143 Handout 20 Summer 2011 July 15 th, 2011 CS143 Practice Midterm and Solution

COMPUTER SCIENCE TRIPOS

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Representing and Manipulating Floating Points

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

Numeric Encodings Prof. James L. Frankel Harvard University

Compiler Design 1. Bottom-UP Parsing. Goutam Biswas. Lect 6

±M R ±E, S M CHARACTERISTIC MANTISSA 1 k j

COMPUTER SCIENCE TRIPOS

The SPIN Model Checker

Assignment-2 (TCS/TIT 503)

MITOCW watch?v=kz7jjltq9r4

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

Exam 3 Practice Problems

G52CON: Concepts of Concurrency

Turing Machine Languages

Programming Lecture 3

CS 370 Operating Systems

1993 Paper 2 Question 10

COMPUTER SCIENCE TRIPOS

Representing and Manipulating Floating Points

Important Project Dates

CSCI312 Principles of Programming Languages!

Principle of Complier Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore

IEEE Standard 754 Floating Point Numbers

Theory of Computations Spring 2016 Practice Final

2 Copyright 2015 M. E. Kabay. All rights reserved. 4 Copyright 2015 M. E. Kabay. All rights reserved.

Representing and Manipulating Floating Points. Jo, Heeseung

Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy.

DADI INSTITUTE OF ENGINEERING & TECHNOLOGY (Approved by A.I.C.T.E., New Delhi & Affiliated to JNTUK, Kakinada)

Formal Languages and Compilers Lecture VII Part 3: Syntactic A

Error-Correcting Codes

COMPUTER SCIENCE TRIPOS

Chapter 9 Graph Algorithms

CSE 120 PRACTICE FINAL EXAM, WINTER 2013

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Question Score Points Out Of 25

We show that the composite function h, h(x) = g(f(x)) is a reduction h: A m C.

CS 261 Fall Floating-Point Numbers. Mike Lam, Professor.

Chapter 9 Graph Algorithms

(a) Give inductive definitions of the relations M N and M N of single-step and many-step β-reduction between λ-terms M and N. (You may assume the

EDAN65: Compilers, Lecture 06 A LR parsing. Görel Hedin Revised:

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

LL Parsing, LR Parsing, Complexity, and Automata

Scientific Computing. Error Analysis

Binary floating point encodings

Transcription:

CST.95.3.1 COMPUTER SCIENCE TRIPOS Part IB Monday 5 June 1995 1.30 to 4.30 Paper 3 Answer five questions. Submit the answers in five separate bundles each with its own cover sheet. Write on one side of the paper only. 1 Concurrent Systems Why are database transactions necessary? Describe the ACID properties of transactions. What are the differences between optimistic and pessimistic mechanisms of concurrency control (with particular reference to the ACID properties)? What factors determine whether an optimistic or pessimistic concurrency control policy is appropriate for a transaction processing system? With reference to these factors, state whether an optimistic or pessimistic policy would lead to a more efficient system in the following cases: (a) a flight booking system (b) (c) a police criminal record database a banking transaction processing system (d) a database maintaining patient records 1 [TURN OVER

CST.95.3.2 2 Further Modula-3 Synchronisation of threads in Modula-3 is achieved through the use of mutexes and condition variables. An alternative scheme would be to use Dijkstra semaphores. A semaphore has a hidden value (usually set to 1 initially) and two atomic operations: wait (sometimes called P) decrements the stored value. negative, the thread is suspended; otherwise it continues. If the result is signal (sometimes called V) increments the value. If there are any other threads suspended while waiting for the semaphore, one of them is allowed to continue. Write an interface Semaphore defining an opaque object type T with init, signal and wait methods. Sketch an implementation of the Semaphore module giving a concrete revelation of T and implementing appropriate default methods. [10 marks] Show how the interface and implementation could be extended to derive a sub-type of T with an extra method, try, which works like wait but returns a BOOLEAN value instead of blocking. In the normal case, try should return TRUE but when the thread would have been suspended, the value in the semaphore is left unchanged and it should return FALSE. 3 Regular Languages and Finite Automata Describe how to derive from any regular expression a deterministic finite automaton describing the same language. [15 marks] Justify the claim that the resulting automaton does describe the same language. 2

CST.95.3.3 4 Compiler Construction Construct the characteristic finite state machine for the following grammar. S A B eof A A B B a B (A) b [6 marks] Explain what is meant by the FOLLOW set for a non-terminal symbol in a grammar, and derive the FOLLOW sets for A and B in the above grammar. Construct, with explanation, the SLR(1) action and goto matrices for the above grammar. Illustrate how the SLR(1) parsing algorithm works for this grammar by showing the successive states of the parser stack and input stream while parsing b a b ( b a ) eof 3 [TURN OVER

CST.95.3.4 5 Data Structures and Algorithms For each of the following situations identify one data structure or algorithm that it would be sensible to use, and another that would in principle achieve the desired result but which would have significant disadvantages. You may identify standard methods by name and need not describe in detail how they work, but should make it clear what properties the schemes that you identify have that make some of them more appropriate than others. (a) You need to represent some (directed) graphs where when a graph has N vertices it will have around N log N edges. The number of vertices, N, may become quite large. (b) (c) In the process of rendering a graphical image you have already sorted all the objects that have to be drawn with an ordering based on their distance from the viewpoint. Now the image has been changed slightly so that you can start to display the next frame of the video sequence, so all the distances have changed, and you need to sort the objects again. You need to build a table. It will be possible to insert objects into the table or retrieve previously stored ones. The only operation you are permitted to perform on objects is a pair-wise comparison that can tell if two objects are equal and if not indicates an ordering between them. There will be both plenty of insertion operations and plenty of lookups. (d) You need to find the shortest distance (through a directed graph that has lengths associated with each edge) from a nominated source point A to each of a collection of destinations {B i }. (e) Blocks of material, each identified by a key, are to be stored on a large disc. From time to time new blocks (and associated keys) will need to be added, but mostly you need to service requests where a user submits a key and wants the corresponding information recovered. There is so much data that the disc is fairly full. 4

CST.95.3.5 6 Data Structures and Algorithms A reasonable approximation for the average number of probes to insert a new entry into an open hash table where a fraction β of the table is already in use is 1/(1 β). Suppose that data is stored by initially creating a really tiny hash table (say a vector of size just 8). Entries are added to the table from time to time. Whenever the table becomes 3/4 full a new hash table, twice the size, is created: all existing data is taken out of the old table, and inserted instead into the new one. Thus in general the table that is in use will be between 3/8 and 3/4 full, and looking things up in it will be efficient. Although the above method has good predicted costs for retrieving information stored in the table, there remains some worry that the repeated cost of copying data from smaller to larger tables may be excessive. Suppose that at some stage N items have been inserted and that the very last insertion provoked the copying step. Estimate the ratio between the total number of hash probes performed while building the table and N. How does it compare with the number that would have been used if the table had been built full-sized to start with rather than having to grow stage by stage on the way? [20 marks] [If you really need their values, you may assume that ln(2) = 0.7, ln(3) = 1 and ln(5) = 1.6, but note that you are not expected to perform any arithmetic tedious enough to call for a calculator: a reasonable estimate (for example to within a factor of 1.5) and a justification of how that value was arrived at is what is required.] 7 Operating System Functions What properties of file access and of discs does a log-structured file system use to optimise file system performance? Describe scenarios in which the relevant assumptions are valid and invalid. [8 marks] Describe the operation of such a file system, including the actions of the sweep, or garbage collection, stage, and how the system recovers from crashes. [12 marks] 8 Unix Case Study Describe the segments that compose a Unix process and how the exec functions create these segments from the sections of an executable binary file. [8 marks] Using as an example the command line ls wc, describe the sequence of operations and system calls that a shell must perform to execute the commands to the point at which an exec function is invoked on each of ls and wc. [12 marks] 5 [TURN OVER

CST.95.3.6 9 Computation Theory Give a brief explanation of each of the following: (a) the encoding of register machine programs as numbers (b) the notion of a universal register machine [3 marks] (c) the notion of a register machine decidable subset of N = {0, 1, 2,...} [2 marks] Assuming the existence of a universal register machine, or otherwise, show that there is a unary computable partial function f(x) such that both {x N f(x) is defined} and {y for some x, f(x) = y} are register machine undecidable. If you appeal to the undecidability of the Halting Problem, you must prove it. (You may assume the existence of register machines for coding and decoding pairs of numbers as numbers.) [10 marks] 10 Numerical Analysis I For Single Precision in the IEEE binary floating point standard (IEEE 754) the precision is defined as 24, and the exponent requires 8 bits of storage. With reference to IEEE Single Precision, explain the terms exponent, significand, precision, sign bit, normalised number, denormal number, hidden bit. [7 marks] How many bits are required to store a Single Precision number? How is the exponent stored? What is the value of the hidden bit for (a) normalised, and (b) denormal numbers? [3 marks] Define the terms absolute error, relative error, machine epsilon. [3 marks] Suppose x = 4.0027, y = 4.0047 are numbers represented on a computer with machine epsilon = 0.5 10 4. Estimate roughly (i) the maximum absolute error, and (ii) maximum relative error in evaluating (y x). Use your results to explain the term loss of significance. [7 marks] 6