where the records in table S 0 will contain the precomputed values for this query. In this
Question:
where the records in table S 0 will contain the precomputed values for this query. In this way the common and expensive query can be answered by a single key-based read. (Note: Sum should be 0 if no matching records exist.) (a) Explain how the operation insert (a, b) into S can be correctly implemented in the {S 0 , R, T} database. [4 marks] (b) Explain how the operation insert (c, v) into T can be correctly implemented in the {S 0 , R, T} database. [4 marks] (c) Explain how the operation insert (a, c) into R can be correctly implemented in the {S 0 , R, T} database. [4 marks] (d) For an OLTP database, discuss the performance implications of this so-called optimisation. [4 marks] (e) This example illustrates a fundamental trade-off in the design and implementation of database applications. Discuss. [
A software module controls a car park of known capacity. Calls to the module's procedures enter () and exit() are triggered when cars enter and leave via the barriers. Give pseudocode for the enter and exit procedures (i) if the module is a monitor [8 marks] (ii) if the programming language in which the module is written provides only semaphores [4 marks] (b) Outline the implementation of (i) semaphores [4 marks] (ii) monitors [4 marks]
In a proposed, next-generation banking system a number of transactions are to be scheduled to run concurrently: ? Debit (D) transactions to make payments from customer accounts to a credit card company. ? Interest (I) transactions to add daily interest to customer account balances. ? Transfer (T) transactions which first check whether the source account contains sufficient funds then either abort or continue the transfer from source to destination accounts. Customer x is running a T to transfer 1000 from A to B. Customer y is running a (a) Discuss the potential for interference between any of these transactions. [7 marks] (b) Demonstrate the effect of concurrency control based on strict two-phase locking in relation to the discussion in (a). [8 marks] (c) Comment on the scope of concurrency control in relation to the discussion in (a). [5 marks] [Hint: you may assume that operations on bank account objects, such as debit, credit and add-interest are atomic.]
You are asked to write Prolog program to work with binary trees. Your code should not rely on any library predicates and you should assume that the interpreter is running without occurs checking. (a) Describe a data representation scheme for such trees in Prolog and demonstrate it by encoding the tree shown above. [3 marks] (b) Implement a Prolog predicate bfs/2 which effects a breadth-first traversal of a tree passed as the first argument and unifies the resulting list with its second argument. For example, when given the tree shown above as the first argument the predicate should unify the second argument with the list [3,2,7,4,2,5]. [4 marks] (c) Explain why the bfs/2 predicate might benefit from being converted to use difference lists. [2 marks] (d) Implement a new predicate diffbfs/2 which makes use of a difference list to exploit the benefit you identified in part (c). Your predicate should take the same arguments as bfs/2. [6 marks] (e) A friend observes that a clause in diffbfs/2 will need to contain an empty difference list and proposes two possible ways of representing it, either []-[] or A-A. Consider your implementation of diffbfs/2. For each use of an empty difference list, justify your choice and explain what can go wrong using the alternative form. [2 marks] (f ) Is your implementation amenable to last call optimisation (LCO)? If so, explain why. If not, give details of the minimal changes you would make to make LCO possible. [3 marks
Discuss the merits of translating the abstract syntax tree representation of a program into assembly language by means of (a) an ad hoc recursive tree walking program [10 marks] (b) an algorithm based on tables automatically generated from tree translation rules [10 marks]
Give a brief description of the main features of Lex and Yacc. [5+5 marks] Illustrate their use by outlining how you would construct a parser for expressions composed of identifiers, integers, function calls and the operators *, /, + and -. [10 marks]
Discuss the issues that must be considered when designing the calling sequence to be used for recursive procedures on a machine with several general-purpose central registers. Assume that the language allows procedures to be declared within other procedures and that procedures may be passed as arguments in calls. Pay particular attention to how arguments, local variables and free variables are accessed. [20 mark
Write notes on each of the following topics: (a) the implementation of labels and jumps in a recursive, block structured programming language [7 marks] (b) the implementation of arrays with non-constant bounds [7 marks] (c) problems in the specification and implementation of Algol own variables [6 marks]
) (i) What is meant by the address space of a process? (ii) Give an example of how a 32-bit address space might be allocated between the various components of user and operating system (OS) code and data. You may assume that the process. (iii) Why does the OS region containing memory-mapped I/O interfaces need to be distinguished? What is the alternative to memory-mapped I/O? (iv) How might the fact that much OS code must be permanently resident in memory be used to advantage? (v) How is the OS protected from user level code at runtime? (vi) How is the OS executed synchronously via calls from user level? [13 marks] (b) In what way did the provision of a protected address space per process affect the development of operating systems? Describe the hardware and software support for the development you mention in some detail
This assignment gives you an opportunity to learn about files, arrays, and pointers. A cost involves a Description, and an amount and An Item Number.
Write program that opens a file, reads records into a container of data structures, and prints out the sum in order. You can use Vectors to contain the data structures.
1. Create data structure to represent the record ==> struct Cost in cost.h 2. Write function called ==> parse_account, that parses one (string) record from a file, and populates a data structure with that data.
Data Analysis and Decision Making
ISBN: 978-0538476126
4th edition
Authors: Christian Albright, Wayne Winston, Christopher Zappe