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

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.

Python programming: Exception Handling Example: Please read carefully. Consider the following functionwhich divides a number by zero; def calc(x): x / O This

Python programming: Exception Handling Example: Please read carefully. Consider the following function which divides a number by zero; def calc(x): x / O This will raise an error when it is run for any number: If we now call this function, we will get the error trackback in the standard output: calc(6) However, we can handle this by wrapping the call to runcalc within a try statement and providing an except clause. The syntax for a try statement with an except clause is: try: calc(6) except: print("oops") which now results in the string 'oops' being printed out. This is because when runcalc is called the '/' operator throws the ZeroDivision Error which is passed back to the calling code which has an except clause specifying this type of exception. This catches the exception and runs the associated code block which in this case prints out the string 'oops. Here's an alternative way to write the above code: try: calc(6) except ZeroDivision Error:print('oops") Q1. Write a program that accepts two integer inputs from the user and checks if one integer evenly divides another. In your solution, you are required to implement exception handling to check user inputs for validity and also to avoid ZeroDivision Error in the output. You may use a Python function exit(0), which exits the program immediately, skipping anything that comes after it Q2. You are in country where there are two conditions for fishing: (a) you can fish if you are 17 years old or less and your parent has a license. (b) If you are 18 years old or more you need to have your own license. Write a program that tells someone if they are legal to fish. First ask them how old they are, whether they have a license or not, and whether their parent has a license or not. Add exception handling to the program so that if the user answers something other than their age that the program prints "You did not enter your age correctly" Q3. Consider the following program (an example of continuous menu) D=["Sara', 3.40, '04235;IT'] def runMenu(): choice=1 while not choice==0: print("Please enter your choices:") print("1- to print your Name") print("2- to print your GPA") print("3- to print your Contact") print("4- to print your major") print("0- to Exit") choice=int(input()) print(D[choice-1]) runMenu() Questions: a. List all the errors might happen due to some unexpected inputs b. Fix them using exception handling concept

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!