CANMNMM January of this year. (a) Each item will be held in a record.
Question:
CANMNMM
January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the fields that the record must have to implement the required functionality, and how each of these fields has to be updated and when. [5 marks] (b) The obvious baseline solution is to re-sort the n items and to take the top k every time the bestseller lists must be produced. Assuming the number of items and the given average rates stay constant, what is its asymptotic worst-case time cost per unit time? [1 mark] (c) Describe three alternative strategies, each better than the baseline, to implement the required functionality. Use the heaps or search trees of your choice, explaining precisely what you would store in each data structure to implement the required functionality. Describe, in each case, how to initialize the data structures, how to update the data structures after each sale, how to recompute the three bestseller lists every s seconds, together with the worst-case asymptotic time cost of each operation as a function of m, n, k, s (cost per unit time for the second and third operations). [6 marks] (d) Recommend the most appropriate strategy for m = 104 , n = 109 , k = 102 , s = 100 , with justification. [2 marks] (e) Repeat for n = 1014 and the other parameters unchanged. [3 marks] (f ) Repeat for m = 10−4 , n = 102 , k = 101 , s = 105 , reasoning about the structural difference between this and the websites of cases (d) and (e). [3 marks] 9 CST0.2021.1.10 9
Algorithms Consider a directed graph in which each edge is labelled by a pair of non-negative costs, for example a distance and a travel time. A path between a pair of nodes is called 'Pareto efficient' (after the economist Vilfredo Pareto) if there is no other path for which both costs are lower. (a) In the graph shown here, find all Pareto efficient paths from s to t, and state their costs. [1 mark] (b) Show that, if v0 → v1 → · · · → vk is a Pareto efficient path from v0 to vk, then v0 → · · · → vk−1 is a Pareto efficient path from v0 to vk−1. [3 marks] (c) Let v0 → · · · vk be a Pareto efficient path from v0 to vk, and let its costs be (ca, cb). Show that there is a Pareto efficient path from v0 to vk with costs (ca, cb) that has ≤ V − 1 edges, where V is the number of vertices in the graph. [3 marks] (d) We are given a start vertex s. Give an algorithm to compute all costs achievable by Pareto efficient paths from s to every other vertex. [6 marks] (e) Prove that your algorithm is correct. [7 marks] 10 CST0.2021.1.11 10 Algorithms This question is concerned with connected undirected graphs in which each edge has a weight, and with spanning trees in such graphs. (a) Explain what is meant by the translation strategy, and outline briefly the steps of a translation-based proof of correctness. [3 marks] (b) Give an algorithm for finding a maximum spanning tree, that runs in O(E + V log V ) time. Explain why your algorithm's running time is as required. [8 marks] (c) Prove rigorously that your algorithm is correct. [9 marks] [Note: You may refer to algorithms from lecture notes without quoting the code. You may use results from lecture notes without proof, but you must state them clearly
1 Digital Electronics (a) Show that (i) (X + Y ).(X + Y ) = X ( CST0.2021.2.3 2 Digital Electronics The figure below shows a circuit using an N-channel MOSFET, along with a table giving the relationship between VDS and IDS for various values of VDS, at VDD = 4 V and VGS = 4 V. R 0V V DD V1 V2 VDS(mV) 160 320 470 IDS(mA) 48 92 130 (a) Calculate the value of resistor R and the power dissipated in it when VDS = 160 mV. [4 marks] (b) A capacitor C is connected between the source and drain terminals of the MOSFET. After the MOSFET turns OFF at t = 0, the output signal V2 as a function of time t is given by V2 = VDD(1 − e −t/CR). Assume that prior to t = 0, the MOSFET is ON and V2 = 0 V. (i) Determine an expression for the time taken tr, for the output signal V2 to rise from 20% to 80% of its maximum value. (ii) What is the rise time tr, if C = 0.1 µF and R takes the value calculated in Part (a)? (iii) The value of R is changed so as to reduce the rise time to half that in Part (b)(ii). What is the new value of R? (iv) Using the value of R calculated in Part (b)(iii), what is the power dissipated in R when the MOSFET is ON (i.e., when VGS = 4 V), and assuming that V2 = 320 mV? (v) Explain how the problem of high static power consumption seen in the N-channel MOSFET circuit can be eliminated. [9 marks] [continued . . . ] 3 CST0.2021.2.4 (c) The logic gate in the following figure has 3 inputs, A, B, and C, and a single output Y . Determine the truth-table for the gate input to output function, and then determine a simplified Boolean expression for output Y in terms of A, B, and C. VDD 0V A B C Y [7 marks] 4 CST0.2021.2.5 SECTION B .RK
A library defines a generic class Foo in a Java-like language. A user's program declares a class C and subclasses it as class D, creating variables fc and fd of types Foo and Foo respectively. (i) Construct a declaration of Foo along with a program of the above form containing the assignment fc= marks] indicating any compensating restrictions required for the declaration of Foo or fc to avoid run-time errors. [3 marks] (iii) How do Java arrays of type T[] fit in with your answer to Part (c)(i)? [2 marks] 2 CST1.2019.7.3 2 Economics, Law and Ethics (a) Describe five different types of auctions. [5 marks] (b) If you were in the business of selling advertisements, what would be an efficient way to price them? [5 marks] (c) How might one political candidate achieve a better price per advertisement than their opponents? [5 marks] (d) What are bidding rings and what might game theory tell us about them? [5 marks] 3 (TURN OVER) CST1+CST2.2019.7.4 3 Economics, Law and Ethics (a) What do sections 1, 2 and 3 of the Computer Misuse Act 1990 prohibit? [6 marks] (b) Eve is operating a DDoS-for-hire service and has recruited 100,000 CCTV cameras into a botnet. If Mallory pays Eve $2 to take down a gaming teamspeak server for five minutes, what offences, if any, are being committed by Eve and Mallory? [8 marks] (c) How might the Wimbledon case (R v. Lennon 2005 ) apply to this case? [6 marks] 4 CST1+CST2.2019.7.5 4 Formal Models of Language This question relates to an information source that produces symbols from an alphabet. (a) X is an information source, which produces symbols from the set {a, b, c, d, S} (i) If we assume X produces symbols with equal probability, what is the entropy of X? [1 mark] (ii) In fact, X produces symbols with non-equal probabilities. What do you know about the entropy of X compared to your previous answer? [1 mark] (iii) X produces symbols with probability distribution: p(a) = 0.4, p(b) = 0.2, p(c) = 0.2, p(d) = 0.1, p(S) = 0.1 Give an expression for the entropy of information source X. [2 marks] (b) The symbol sequence produced by X represents consecutive words of a language, where S indicates whitespace. (i) Describe and provide an equation for the entropy of the language produced by the symbol sequence. [2 marks] (ii) A student observes that when a word in the language contains c it is always followed by b. Explain how this redundancy helps communication over a channel that tends to swap b with d. [2 marks] (c) Define a noisy channel and describe how it could be interpreted with respect to human language communication. [6 marks] (d) Computational Linguists have hypothesised that natural languages have evolved to be both efficient and robust to noise. Do you agree? Justify your answer by referring to information theory and giving appropriate examples. [6 marks] 5 (TURN OVER) CST1+CST2.2019.7.6 5 Formal Models of Language This question concerns lexical grammars. (a) Tree Adjoining Grammars contain two types of elementary tree. (i) What are these trees called? [1 mark] (ii) If one were building a grammar for English which aspects of language do the two tree types model? [2 marks] (b) Provide a Tree Adjoining Grammar that can parse the string: students enjoy easy exams [5 marks] (c) Show how a parse for this string is constructed. Explain the operations. [5 marks] (d) Provide a Categorial Grammar that can parse the same sentence. [4 marks] (e) When children learn their first language they usually acquire nouns before verbs before modifiers. They also usually produce single word strings before moving on to longer strings. With reference to Tree Adjoining Grammars and/or Categorial Grammars propose some hypotheses for this. Justify your proposals. [3 marks]
1 Foundations of Computer Science Three alternative representations for non-negative integers, n, are: • Peano: values have the form S(... S(Z) ...), applying S n times to Z where S and Z are constructors or constants of some data type. • Binary: values are of type bool list with 0 being represented as the empty list, and the least-significant bit being stored in the head of the list. • Church: values have the form fn f => fn x => f(... f(x) ...), applying f n times to x (a) Write ML functions for each of these data types which take the representation of an integer n as argument and return n as an ML int. [6 marks] (b) Write ML functions for each of these data types which take representations of integers m and n and return the representation of m + n. Your answers must not use any value or operation on type int or real. [Hint: you might it useful to write a function majority: bool*bool*bool -> bool (which returns true when two or more of its arguments are true) and to note that the ML inequality operator '<>' acts as exclusive-or on bool.] [10 marks] (c) Letting two and three respectively be the Church representations of integers 2 and 3, indicate whether each of the following ML expressions give a Church representation of some integer and, if so what integer is represented, and if not giving a one-line reason. (i) two three (ii) three two (iii) two ◦ three (iv) three ◦ two [4 marks] 2 CST0.2019.1.3 2 Foundations of Computer Science (a) We are interested in performing operations on nested lists of integers in ML. A nested list is a list that can contain further nested lists, or integers. For example: [[3, 4], 5, [6, [7], 8], []] We will use the datatype: datatype nested_list = Atom of int | Nest of nested_list list; Write the code that creates a value of the type nested list above. [1 mark] (b) Write the function flatten that flattens a nested list to return a list of integers. [3 marks] (c) Write the function nested map f n that applies a function f to every Atom in n. [4 marks] (d) What is the type of f in Part (c)? [1 mark] (e) Write a function pack as xs n that takes a list of integers and a nested list; the function should return a new nested list with the same structure as n, with integers that correspond to the integers in list xs. Note: It is acceptable for the function to fail when the number of elements differ. Example: > pack_as [1, 2, 3] (Nest [Atom 9, Nest [Atom 8, Atom 7]]); val it = Nest [Atom 1, Nest [Atom 2, Atom 3]]: nested_list [6 marks] (f ) What does the data type nested zlist correspond to? [2 marks] datatype nested_zlist = ZAtom of int | ZNest of (unit -> nested_zlist list); (g) Write the function that converts a nested zlist to a nested list. [3 marks] 3 (TURN OVER) CST0.2019.1.4 SECTION B 3 Object-Oriented Programming (a) You are given the following implementation for an element of a list: class Element { int item; Element next; Element(int item, Element next) { super(); this.item = item; this.next = next; } @Override public String toString() { return item + " " + (next == null ? "" : next); } } (i) What does the statement super() mean? [1 mark] (ii) What is the meaning of this in the line this.item = item? [1 mark] (iii) What is the purpose of the annotation @Override? [2 marks] (iv) Rewrite the class to be immutable. You may assume that there are no sub-classes of Element. [2 marks] (b) Use the immutable Element class to provide an implementation of an immutable class FuncList which behaves like an int list in ML. Your class should include a constructor for an empty list and methods head, tail and cons based on the following functions in ML. Ensure that your class behaves appropriately when the list is empty. [6 marks] fun head x::_ = x; fun cons (x,xs) = x::xs; fun tail _::xs = xs; (c) Another developer changes your implementation to a generic class FuncList that can hold values of any type T. (i) This means that FuncList is no longer immutable. Explain why and what could be done to remedy this. [2 marks] (ii) Java prohibits covariance of generic types. Is this restriction necessary in this case? Explain why with an example. [6 marks] 4 CST0.2019.1.5 4 Object-Oriented Programming (a) What is an object? [2 marks] (b) Give four examples of how object-oriented programming helps with the development of large software projects and explain why each one is helpful. [8 marks] (c) Explain the meaning of the Open-Closed principle. [2 marks] (d) Draw a UML diagram for a design satisfying the Open-Closed principle and explain why it satisfies it. [8 marks] 5 (TURN OVER) CST0.2019.1.6 SECTION C 5 Numerical Analysis (a) Let f be a single variable real function that has at least one root α, and that admits a Taylor expansion everywhere. (i) Starting from the truncated form of the Taylor expansion of f(x) about xn, derive the recursive expression for the Newton-Raphson (NR) estimate xn of the root at the (n + 1)th step. [1 mark] (ii) Consider the general Taylor expansion of f(α) about xn. Using big O notation for an appropriate Taylor remainder and denoting the NR error at the nth step by en, prove that the NR method has quadratic convergence rate. That is, show that en+1 is proportional to e 2 n plus a bounded remainder. State the required conditions for this to hold, paying attention to the interval spanned during convergence. [6 marks] (iii) Briefly explain two of the known problems of the NR method from an implementation standpoint or otherwise. [2 marks] (b) Let f(x) = x 2 − 1. Suppose we wish to find the positive root of f using the Newton-Raphson (NR) method starting from an initial guess x0 ≥ 1. (i) Show that if x0 ≥ 1 then xn ≥ 1 for all n ≥ 1. [3 marks] (ii) Thus find an upper bound for NR's xn+1 estimate in terms of xn and in turn find an upper bound for xn in terms of x0. [5 marks] (iii) Using the above, estimate the number of NR iterations to obtain the root with accuracy 10−9 for a wild initial guess x0 = 109 . [Hint: You may wish to approximate 103 by 210.] [3 marks] 6 CST0.2019.1.7 6 Numerical Analysis (a) You are given a system of real equations in matrix form Ax = b where A is non-singular. Give three factorization techniques to solve this system, depending on the shape and structure of A: tall, square, symmetric. For each technique, give the relevant matrix equations to obtain the solution x, and point out the properties of the matrices involved. Highlight one potential problem from an implementation (computer representation) standpoint. [Note: You do not need to detail the factorization steps that give the matrix entries.] [5 marks] (b) We want to estimate travel times between stops in a bus network, using ticketing data. The network is represented as a directed graph, with a vertex for each bus stop, and edges between adjacent stops along a route. For each edge j ∈ {1, . . . , p} let the travel time be dj . The following ticketing data is available: for each trip i ∈ {1, . . . , n}, we know its start time si , its end time fi , and also the list of edges it traverses. The total trip duration is the sum of travel times along its edges. We shall estimate the dj using linear least squares estimation, i.e. solve arg minβ ky − Xβk 2 for a suitable matrix X and vectors β and y. (i) Give an example of ticket data for a trip traversing 5 edges, and write the corresponding equation of its residual. [1 mark] (ii) Give the dimensions and contents of X, β, and y for this problem. State a condition on X that ensures we can solve for β. [3 marks] (iii) Give an example with p = 2 and n = 3 for which it is not possible to estimate the dj . Compute XT X for your example. [2 marks] (c) Let A be an n × n matrix with real entries. (i) We say that A is diagonalisable if there exists an invertible n × n matrix P such that the matrix D = P −1AP is diagonal. Show that if A is diagonalisable and has only one eigenvalue then A is a constant multiple of the identity matrix. [3 marks] (ii) Let A be such that when acting on vectors x = [x1, x2, . . . , xn] T it gives Ax = [x1, x1 −x2, x2 −x3, . . . , xn−1 −xn] T . Write out the contents of A and find its eigenvalues and eigenvectors. Scale the eigenvectors so they have unit length (i.e. so their magnitude is equal to 1). [6 marks] 7 (TURN OVER) CST0.2019.1.8 SECTION D 7 Algorithms (a) The Post Office of Maldonia issued a new series of stamps, whose denominations in cents are a finite set D ⊂ N\{0}, with 1 ∈ D. Given an arbitrary value n ∈ N\{0} in cents, the problem is to find a minimum-cardinality multiset of stamps from D whose denominations add up to exactly n. In the context of solving the problem with a bottom-up dynamic programming algorithm. . . (i) Give and clearly explain a formula that expresses the optimal solution in terms of optimal solutions to subproblems. [Note: If your formula gives only a scalar metric (e.g. the number of stamps) rather than the actual solution (e.g. which stamps), please also explain how to obtain the actual optimal solution.] [4 marks] (ii) Draw and explain the data structure your algorithm would use to accumulate the intermediate solutions. [2 marks] (iii) Derive the big-Theta space and time complexity of your algorithm. [1 mark] (b) Repeat (a)(i)-(a)(iii) for the following problem: A car must race from point A to point B along a straight path, starting with a full tank and stopping as few times as possible. A full tank lets the car travel a given distance l. There are n refuelling stations so ≡ A, s1, s2, . . . , sn ≡ B along the way, at given distances d0 = 0, d1, d2, . . . , dn from A. The distance between adjacent stations is always less than l. The problem is to find a minimum-cardinality set of stations where the car ought to refill in order to reach B from A. [7 marks] (c) Which of the two previous problems might be solved more efficiently with a greedy algorithm? Indicate the problem and describe the greedy algorithm. Then give a clear and rigorous proof, with a drawing if it helps clarity, that your greedy algorithm always reaches the optimal solution. Derive the big-Theta time complexity. [6 marks] 8 CST0.2019.1.9 8 Algorithms (a) Consider a Binary Search Tree. Imagine inserting the keys 0, 1, 2, . . . , n (in that order) into the data structure, assumed initially empty. (i) Draw a picture of the data structure after the insertion of keys up to n = 9 included. [2 marks] (ii) Clearly explain, with a picture if helpful, how the data structure will evolve for arbitrary n, and derive the worst-case time complexity for the whole operation of inserting the n + 1 keys. [2 marks] (b) Repeat (a)(i) and (a)(ii) for a 2-3-4 tree, with some scratch work showing the crucial intermediate stages. [2+2 marks] (c) . . . and for a B-tree with t = 3, again showing the crucial intermediate stages. [2+2 marks] (d) . . . and for a hash table of size 7 that resolves collisions by chaining. [2+2 marks] (e) . . . and for a binary min-heap. [2+2 marks] 9 (TURN OVER) CST0.2019.1.10 9 Algorithms A Random Access Queue supports the operations pushright(x) to add a new item x to the tail, popleft() to remove the item at the head, and element at(i) to retrieve the item at position i without removing it: i = 0 gives the item at the head, i = 1 the following element, and so on. (a) We can implement this data structure using a simple linked list, where element at(i) iterates from the head of the list until it reaches position i. (i) State the complexity of each of the three operations. [1 mark] (ii) A colleague suggests that, by defining a clever potential function, it might be possible to show that all operations have amortized cost O(1). Show carefully that your colleague is mistaken. [6 marks] (b) We can also implement this data structure using an array. The picture below shows a queue holding 4 items, stored within an array of size 8. When new items are pushed, it may be necessary to create a new array and copy the queue into it. The cost of creating an array of size n is Θ(n). head item item item tail item 0 1 2 3 4 5 6 7 (i) Give pseudocode for the three operations. Each operation should have amortized cost O(1). [6 marks] (ii) Prove that the amortized costs of your operations are indeed O(1). [7 ma1 (a) (i) Many correct answers, they must be meaningful. This is an example only. StudentNames[1:30] [1] (ii) Many correct answers, they must be meaningful. This is an example only. StudentMarksTest1[1:30] StudentMarksTest2[1:30] StudentMarksTest3[1:30] (1 mark) StudentTotalScore[1:30] (1 mark) [2] (b) (i) - outside loop zeroing total for loop (sum in example below) - loop for all students - input name and all test scores - in loop adding a student's total - storing the total - inside loop printing student's name and total - outside loop calculating class average - printing class average sample algorithm: Sum Å 0 FOR Count Å 1 TO 30 INPUT Name StudentName[Count] Å Name INPUT Mark1, Mark2, Mark3 StudentMarksTest1[Count] Å Mark1 StudentMarksTest2[Count] Å Mark2 StudentMarksTest3[Count] Å Mark3 Total Å Mark1 + Mark2 + Mark3 StudentTotalScore[Count] Å Total Sum Å Sum + Total PRINT StudentName[Count], StudentTotalScore[Count] NEXT Count ClassAverage = Sum/30 PRINT ClassAverage [8] (ii) any relevant comment with regards to efficient code (e.g. single loop) [1] (c) Many correct answers, these are examples only. 1 mark per data set and reason Set 1: 20, 25, 35 Reason: valid data to check that data on the upper bound of each range check is accepted Set 2: 21, 26, 36 Reason: invalid data to check that data above the upper bound of each range check is rejected [2] 3 © UCLES 2019 0478/02/SM/20 [Turn over (d) (i) Maximum 5 marks in total for question part Maximum 3 marks for algorithm Description (max 3) - set variable called HighestScore to zero and variable called BestName to dummy value - loop 30 times to check each student's total score in turn - check student's score against HighestScore - if student's score > HighestScore then - « replace value in HighestScore by student's score and store student's name in BestName - output BestName and HighestScore outside the loop Sample algorithm (max 3): HighestScore Å 0 BestName Å "xxxx" (1 mark) FOR Count Å 1 TO 30 IF StudentTotalScore[Count] > HighestScore (1 mark) THEN HighestScore Å StudentTotalScore[Count] BestName Å StudentName[Count] (1 mark) ENDIF NEXT Count (1 mark) PRINT BestName, HighestScore (1 mark) If algorithm or program code only, then maximum 3 marks [5] (ii) comment on which student(s)' name will be output e.g. The first student with the highest score will be output [1] 4 © UCLES 2019 0478/02/SM/20 Section B 2 (a) 1 mark for value of c and message 51020: value of c: 5 message: PIN OK (1 mark) 5120: value of c: 4 message: error in PIN entered (1 mark) [2] (b) length check [1] 3 Engine Count Number Size Average OUTPUT 0 0 0 1.8 1.8 1 1 2.0 3.8 2 2 1.0 4.8 3 1.3 6.1 4 1.0 7.1 5 2.5 9.6 3 6 2.0 11.6 4 7 1.3 12.9 8 1.8 14.7 5 9 1.3 16.0 10 -1 1.6 1.6, 5 (1 mark) (1 mark) (1 mark) (1 mark) (1 mark) (1 mark) [6] 4 1 mark for each error identified + suggested correction line 5: this should read IF x > h THEN h = x line 7: PRINT h should come after the end of the repeat loop line 8: this should read UNTIL c = 20 or UNTIL c >= 20 or UNTIL c > 19 [3] 5 © UCLES 2019 0478/02/SM/20 [Turn over 5 (a) 5 [1] (b) Field: At Risk Age in Years Type Map Position Table: TREES TREES TREES TREES Sort: Show: 9 9 Criteria: True >100 or: One mark per correct column. [4] 6 (a) marking points: the way to find and print the largest value a 1 mark the way to find and print the largest value b 1 mark the way to find and print the largest value c 1 mark sample algorithm: INPUT a, b, c IF a > b AND a > c THEN PRINT a (1 mark) ELSE IF b > c THEN PRINT b (1 mark) ELSE PRINT c (1 mark) [3] (b) marking points: loop construct 1 mark check if number is an integer 1 mark counting the number of integers input 1 mark output count value (outside the loop) 1 mark sample algorithm: FOR x ← 1 TO 1000 (1 mark) INPUT Number Difference ← INT(number) - Number (1 mark) IF Difference = 0 THEN Total ← Total + 1 (1 mark) NEXT x PRINT total (1 mark) (NOTE: alternative to lines 3 and 4: IF INT(Number) = Number THEN Total ← Total + 1 (2 marks) ) [4] (c) Description of any two sets of test data. Many correct answers, these are examples only. 1000 whole numbers to ensure that loop works properly 900 whole numbers and 100 numbers with decimal places to ensure that the routine distinguishes correctly [2] 6 © UCLES 2019 0478/02/SM/20 7 (a) 7 [1] (b) Hg, Cs [2] (c) Element symbol
For this independent learning activity we'll start with a small exercise of class that can be used to represent the state of a light switch (Off or On). The class will have the ability to check whether the light is currently off or on and to toggle the light to the other state.
After completing the instructions that guide you through the creation of the LightSwitch class you should test it using the code included in the Program.cs class for LightSwitch. Once that is done it is on to the challenge. The challenge is to take the concept of a light switch and extend what you've already done to represent a TrafficLight
What is the essential, underlying reason that low-order foremost
memory interleaving and/or cache reminiscences are wished and used
in without a doubt all high-performance laptop systems?
Four. A principal memory system is designed using 15-ns RAM devices using
a four-manner low-order interleave.
A. What would be the powerful time per foremost memory get entry to underneath
best situations?
B. What might represent ideal situations? (In other words, below
what occasions may want to the access time you simply calculated be
done?)
c. What might constitute worst-case conditions? (In different phrases,
under what occasions would reminiscence accesses be the slowest?) What would the access time be on this worst-case scenario?
If best situations exist 80% of the time and worst-case situations occur 20% of the time, what would be the common time
required in keeping with memory get admission to?
D. When best situations exist, we would really like the processor to be
able to access memory every clock cycle without a wait states (that
is, with none cycles wasted looking forward to memory to respond).
Given this requirement, what is the very best processor bus clock
frequency that can be used with this memory system?
E. Other than accelerated hardware cost and complexity, are there
any potential dangers of the usage of a low-order interleaved
reminiscence design? If so, speak one such disadvantage and the
situations underneath which it is probably substantial.
Five. Is it accurate to consult an ordinary semiconductor integrated circuit
ROM as a random get admission to reminiscence? Why or why now not? Name and
describe different logical organizations of pc reminiscence that
aren't random get right of entry to.
6. Assume that a given device's primary reminiscence has an get right of entry to time of
6.Zero ns, and its cache has an get entry to time of one.2 ns (five times as fast).
What would the hit ratio need to be in order for the powerful reminiscence access time to be 1.5 ns (four times as speedy as principal reminiscence)?
7. A unique software runs on a gadget with cache reminiscence. The application makes a complete of 250,000 reminiscence references; 235,000 of those
Discuss to what extent the notation used in VDM is significantly different from that used in a conventional programming language. [6 marks] Use VDM to specify a function that will find the difference between the largest and the smallest values held in an integer array. [7 marks] 2 CST.93.4.3 4 Prolog The following Prolog clauses define the procedure named reverse. The goal reverse(X,Y) succeeds for the list X, instantiating Y to the reverse of the list X. For example, evaluating the goal reverse([a,b,c],Q) instantiates Q to [c,b,a]. reverse(X,Y) :- rev(X,[],Y). rev([],L,L). rev([H|T],R,Y) :- rev(T,[H|R],Y). Explain how this procedure works, using a small example. [10 marks] What is the outcome of the goal reverse(L,[a,b,c])? Explain your answer carefully. [10 marks] 5 Programming Language Compilation Give a brief description of the main features of Lex and Yacc. [5+5 marks] Illustrate their u EVV
Country A learns that country B is boosting its military in preparation for
a possible invasion. A has a choice between preparing for an invasion, at a
cost if 100 units of wealth, and not preparing, in full view of B's spies. In
case of invasion, a prepared A can choose to destroy its entire infrastructure
at an additional cost of 900 units of wealth, or not to do so. If an invasion
occurs and A's infrastructure is not destroyed country B gains 100 units of
wealth and A loses 100 units of wealth (in addition to the preparation cost
of 100 units, if A has prepared). If an invasion occurs and A's infrastructure
has been destroyed, B loses 5 units of wealth. If no invasion occurs, country
B gets nothing.
(a) Describe this game using a tree, carefully labelling all its components.
(5 marks)
(b) Solve this game using backward induction. (3 marks)
(c) Describe the game in strategic form, find all its pure-strategy Nash
equilibria and indicate which of these is subgame perfect.
(7 marks)
(ii) (a) State Zermello's Theorem for finite, two-player sequential games.
(3 marks)
(b) Consider a game played with 10 dots drawn on a sheet of paper. Two
players, Red and Blue, alternate in choosing a pair of dots which has
not been chosen before by either player, and connecting the two dots
with a line of their colour. Red moves first.
The game ends if either there are four dots pairwise connected
with lines of same colour, in which case that colour is declared the
winner, or if all pairs of points have been connected with a line, but
there is no winner, in which case the game ends with a draw.
Use a strategy stealing argument to prove that there is a
strategy that guarantees a win or a draw to the first player to move.
GPC's primary objective is to increase revenue 7% and net income 6% in each of the next 4 years prior to a planned initial public offering (in year 5).
The company producess. Hans refuses to purchase from large corporate farms.
The company cannot expand at its present location without purchasing additional acreage. The cost of farm land has been increasing 5% per year.
Their product has earned numerous awards which has provided strong name recognition in Wisconsin. They sell to grocery stores, restaurants, organic food outlets, and online customers. They also sell to a wholesale distributor with access to Illinois, Iowa, Michigan and Ohio. The company is seeking store locations and distributors in other states.
The business is wholly-owned by the Schmidt family, but they are considering doing an initial public offering ("going public") in 5 years. Hans owns 60% and is the CEO. His four children each own 10%. The board is composed of the 5 owners and a family friend who is a lawyer. Hans is chairman of the board. The board does not have a separate audit committee. GPC does not have an internal auditor. An annual audit is required by their bank, The Lake Country Bank.
Han's daughter, Leah Scott, CPA, was recently hired as CFO. She replaced her brother Joe who left abruptly after 10 years. Other family members are employed as department heads. Hans encouraged his family to earn advanced degrees and work for other companies before joining the family business.
The company's sales have been increasing rapidly. The company has reinvested in its operations.
GPC's former auditor is Wilks and Company. When Leah became the new CFO, she suggested a change of firms. She explained that it would be easier working with her former colleagues. She was a Wallace and Brace staff auditor for 4 years, and "knows how they operate."
The Organic Cheese Industry
The organic cheese industry is expected to grow 5-8% per year compared to the non-organic segment which are not expected to grow. New competitors are entering the industry because of the higher profit margins. They may use predatory pricing in order to gain market share. GPC is responding by aggressively marketing new products.
GPC's competitive advantage is that they are the first US cheesemaker to win a world-class award. Since Hans is nearing retirement, they are seeking a highly-skilled cheesemaker from France.
The primary business objective is to increase revenue by 7% and net income by 6% per year for the next 4 years. They will do this through developing new products, aggressive marketing, new stores, and adding new markets. They plan to open a new retail store in each of the next 4 years, assuming they are able locate desirable locations. This year GPC hired a new marketing firm and has increased their advertising.
This year, they implemented 2 new policies in which they offer credit to grocery stores with higher credit risk. They feel that their past policies were too restrictive and limited their sales. They are also offering their sales staff bonuses based on a percentage of sales to grocery stores. They believe that this will lead to higher sales and ultimately to greater profits.
Higher income families consume 70% of organic dairy products, and consumption is highest among adults between ages 25 and 65. Most economists predict modest wage growth in the next 5 years. A few economist predict a recession around year 4.
The industry has seen some merger activity in an attempt to benefit from economies of scale. Large cheese manufacturers are launching organic product lines. This will lead to greater price competition.
In the most recent year, 2.56 billion pounds of organic milk products were sold. That amount represented 5 percent of all milk products. More than 2,500 farms in the United States produced organic milk. Nearly 280,000 dairy cows were certified organic, up from 241,112 dairy cows in the previous year. California produces 20% of the annual organic milk produced. Wisconsin, Texas, and New York produce about 10% each.
Some dairy operations manufacture and sell locally. For national distribution, products tend to move from the farm to a cooperative processor and then to a private distributor before reaching retail outlets.
Organic products sell at a price approximately double the price of non-organic products, but they cost more to produce. Organic feed costs more than standard feed, and organic production uses more labor and capital. Grass-fed cows produce less milk.
USDA standards for organic food were implemented in 2002. Organic dairy is raised in a production system that promotes and enhances biodiversity and biological cycles and uses only organic feedstuffs and health protocol. It is based on minimal use of off-farm inputs. Dairy cattle producing organic milk are not given antibiotics and growth hormone stimulants. In general, organic foods are minimally processed with artificial ingredients or preservatives.
Recent mergers in the organic milk industry could result in lower organic milk prices which reduce the price paid to milk producers. There is also concern that the industry is being dominated by mega-farms. The small producers accuse these large operations of not complying with all the organic regulations. The mega-farms have also created excess supply which suppresses milk prices. The imbalance of power could put small family farms out of the industry. The number of family-farms is expected to decrease. This would allow the larger producers to control the market (and price) of milk.
The company subscribes to industry research in order to monitor economic and industry conditions which may affect future sales. They also monitor competitors' prices and products.
Information from Predecessor Auditor, Wilks and Company
The previous auditor replied that they were comfortable working with the staff and management of GPC. The people have integrity, and are open to recommendations.
They expressed admiration for Hans's business instincts and GPC's distribution channels. Hans is nearing retirement, and though the children are equally dedicated to the business, they do not have his skills.
Wilks and Company will allow Wallace and Brace, CPA to review their audit working papers.
Audit Practice Set Part 1: Audit Planning and Risk Assessment
Instructions:
After reading the document entitled "Green Pastures Cheese, LLC: Background" and completing ratios in the preliminary analytical procedures Excel workbook, respond to each question with complete sentences and reasoning to support your answer. Cite sources.
Wallace and Brace CPA assign a partner to screen and recommend (or decline) potential clients prior to acceptance. Discuss at least 4 specific issues which should have been considered prior to accepting GPC as a client and how they impacted the decision. (Consider both positive and negative factors.)
How does the ownership structure of Green Pastures Cheese affect the type of audit and the auditing standards to be applied?
Discuss the extent to which Wallace and Brace CPA may be liable to 3rd parties. Do the 1933 and 1934 Acts apply to this audit? Why or why not?
GPC has adopted 2 new policies which should be considered in planning the audit. Describe the 2 polices and explain how they might lead to material errors. (What accounts could be misstated?)
Identify 3-5 factors which affect GPC's business risk. For each factor indicate a business objective which could be affected by the particular risk.
1 (i) There are n 1 people working on a project. If the ith person contributes
xi 0 hours (1 i n), the resulting utility for each individual j is given
by
uj(x1; : : : ; xn) =
100
Σn
i=1 xi
1 +
Σn
i=1 xi
???? xj
All individuals choose their efforts simultaneously aiming to maximize their
utility.
(a) Find all pure-strategy Nash equilibria, and find the unique symmet-
ric pure-strategy Nash equilibrium, i.e., an equilibrium in which all
people contribute the same number of hours x. Find the value of x,
and the utility for each player in that Nash equilibrium.
(8 marks)
(b) Suppose that the individuals can sign a contract agreeing on their
(equal) contribution to the project. If what utility would each person
obtain? (5 marks)
(ii) Alice and Bob play a game given in strategic form as follows:
I II III
A 2, 1 3, 4 5, 3
B 4, 3 1, 2 2, 1
C 3, 8 0, 6 1, 6
(a) Find all weakly dominated strategies and all strictly dominated
strategies. (2 marks)
(b) Eliminate iteratively all strictly dominated strategies. (2 marks)
(c) Find all pure-strategy and all mixed-strategy Nash equilibria of this
game.
2 (i) Consider a finite, two-player, zero-sum game G = (S; T; u).
(a) Describe the sets ΔR and ΔC of mixed strategies of both players.
(2 marks)
(b) Define the value of the game G. (2 marks)
(c) Define what optimal strategies of G are. (2 marks)
(d) Let p and q be optimal mixed strategies for the row and column
players, respectively. Show that (p; q) is a Nash equilibrium.
(7 marks)
(ii) A magic square is an nn array where each integer from 1 to n2 occurs and
with the property that all row and column sums are equal. For example,
2
664
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1
3
775
is a 4 4 magic square.
Consider a two-player zero-sum game G whose payoff matrix for the
row player is a n n magic square. Find the value of G and find optimal
strategies for both players. Explain your answer in detail. (12 marks)
MAS348
1 (i) Alice and Bob participate in a first-price sealed-bid auction, by bidding £a
and £b respectively, where a and b are integers satisfying 0 a 3 and
0 b 3. When the bids are revealed, if there was a highest bid, the
person who made that bid pays the amount of the bid and receives the
object. If a = b, a winner is chosen randomly by tossing a fair coin, and
the person chosen as winner pays their bid and receives the object.
The object on sale is worth £3 for Alice and £2 for Bob.
(a) Describe this auction as a game in normal form in which players'
utilities are the expected values of their profits. (6 marks)
(b) Find all weakly dominated strategies and all strictly dominated
strategies. (6 marks)
(c) Find all pure-strategy Nash equilibria of this game. (5 marks)
(ii) Alice Inc. and Bob Plc. form a duopoly in the market for kryptonite. The
cost of producing 1 gram of kryptonite is £10 for Alice and £20 for Bob.
The price p(q) of one gram of kryptonite as a function of its supply q in
grams is given by p(q) = 1000 − q/10. Alice and Bob will decide their
production levels independently and simultaneously.
Find a production profile which results in a Nash equilibrium.
(8 marks)
2 (i) Alice and Bob face the following game in normal form
l m r
U 1, 2 3, 0 1, 3
M -1, 3 2, 5 0, 4
D 0, 5 7, 0 3, 2
(a) Eliminate iteratively all dominated strategies. (2 marks)
(b) Find all Nash equilibria of this game. (11 marks)
(ii) Alice and Bob face the following game
l r
U 0, 0 4, 4
D 2, 7 9, 3
and choose to negotiate an outcome, with the knowledge that, if they fail
to strike a deal, utilities of 3 will be imposed on both.
(a) Sketch the cooperative payoff region of the game. (4 marks)
(b) Describe parametrically the payoffs that satisfy the Individual Rationality
and Pareto Optimality conditions. (3 marks)
(c) Find the Nash Bargain of this setup. (5 marks)
MAS348 3 Turn Over
MAS348
3 (i) Country A learns that country B is boosting its military in preparation for
a possible invasion. A has a choice between preparing for an invasion, at a
cost if 100 units of wealth, and not preparing, in full view of B's spies. In
case of invasion, a prepared A can choose to destroy its entire infrastructure
at an additional cost of 900 units of wealth, or not to do so. If an invasion
occurs and A's infrastructure is not destroyed country B gains 100 units of
wealth and A loses 100 units of wealth (in addition to the preparation cost
of 100 units, if A has prepared). If an invasion occurs and A's infrastructure
has been destroyed, B loses 5 units of wealth. If no invasion occurs, country
B gets nothing.
(a) Describe this game using a tree, carefully labelling all its components.
(5 marks)
(b) Solve this game using backward induction. (3 marks)
(c) Describe the game in strategic form, find all its pure-strategy Nash
equilibria and indicate which of these is subgame perfect.
(7 marks)
(ii) (a) State Zermello's Theorem for finite, two-player sequential games.
(3 marks)
(b) Consider a game played with 10 dots drawn on a sheet of paper. Two
players, Red and Blue, alternate in choosing a pair of dots which has
not been chosen before by either player, and connecting the two dots
with a line of their colour. Red moves first.
The game ends if either there are four dots pairwise connected
with lines of same colour, in which case that colour is declared the
winner, or if all pairs of points have been connected with a line, but
there is no winner, in which case the game ends with a draw.
Use a strategy stealing argument to prove that there is a
strategy that guarantees a win or a draw to the first player to move.
(7 marks)
MAS348
1 Short Answer Questions
1. The price elasticity of demand for gasoline is -2%. If the government wants to reduce gasoline
consumption by 20% how much should it increase the price of gasoline?
2. The cross-price elasticity of good x as a consequence of an increase in the price of good y is -0:5.
Are goods x and y substitutes or complements?
3. Suppose that 2 identical rms produce the same good at marginal cost c and they compete a la
Bertrand. Draw the best response of Firm 1.
4. When do we say that a rm has market power? Can you name two sources of market power?
5. Suppose that the elasticity of demand for cars in Germany is -2 and -3 in the U.K., while the
marginal cost of these cars is $20,000. How will prices dier in Germany and the U.K..
2 Monopoly, Cournot and Stackelberg KEY -
The market demand function for gelato in Summersville is
Qd = 70 ????
P
2
Its cost function for producing gelato is TC = 5 + 20Q.
1. What is xed cost, the variable costs, average costs and marginal costs of producing gelato?
Does the cost function of gelato have economies or diseconomies of scale?
2. Suppose that there is only ONE producer of bathing suits. Find the prot-maximizing quantity
and price for bathing suits.
1
3. Suppose that rm can perfectly price discriminate (rst degree price discrimination). How much
will is produce? How much will its prots be?
4. What will be the equilibrium prices and quantities, if there are TWO rms that choose quantities
simultaneously? (Cournot Competition).
5. Now assume that the rst rm gets to choose quantity before the entrant. What are the quan-
tities that these rms will produce and the price in the market (Stackelberg Competition).
Why are these quantities dierent?
2
1 (i) Alice and Bob participate in a first-price sealed-bid auction, by bidding £a
and £b respectively, where a and b are integers satisfying 0 a 3 and
0 b 3. When the bids are revealed, if there was a highest bid, the
person who made that bid pays the amount of the bid and receives the
object. If a = b, a winner is chosen randomly by tossing a fair coin, and
the person chosen as winner pays their bid and receives the object.
The object on sale is worth £3 for Alice and £2 for Bob.
(a) Describe this auction as a game in normal form in which players'
utilities are the expected values of their profits. (6 marks)
(b) Find all weakly dominated strategies and all strictly dominated
strategies. (6 marks)
(c) Find all pure-strategy Nash equilibria of this game. (5 marks)
(ii) Alice Inc. and Bob Plc. form a duopoly in the market for kryptonite. The
cost of producing 1 gram of kryptonite is £10 for Alice and £20 for Bob.
The price p(q) of one gram of kryptonite as a function of its supply q in
grams is given by p(q) = 1000 − q/10. Alice and Bob will decide their
production levels independently and simultaneously.
Find a production profile which results in a Nash equilibrium.
(8 marks)
2 (i) Alice and Bob face the following game in normal form
l m r
U 1, 2 3, 0 1, 3
M -1, 3 2, 5 0, 4
D 0, 5 7, 0 3, 2
(a) Eliminate iteratively all dominated strategies. (2 marks)
(b) Find all Nash equilibria of this game. (11 marks)
(ii) Alice and Bob face the following game
l r
U 0, 0 4, 4
D 2, 7 9, 3
and choose to negotiate an outcome, with the knowledge that, if they fail
to strike a deal, utilities of 3 will be imposed on both.
(a) Sketch the cooperative payoff region of the game. (4 marks)
(b) Describe parametrically the payoffs that satisfy the Individual Rationality
and Pareto Optimality conditions. (3 marks)
(c) Find the Nash Bargain of this setup. (5 marks)
MAS348 3 Turn Over
MAS348
3 (i)
For all exercises, assume the following parameters:
• Maximum Segment Size (MSS): 1600 Byte
• Initial Window Size (iW): 6
In total, you need to draw 3 individual sequence diagrams including sequence and acknowledgment numbers as well as the amount of data transferred, where applicable. As the assignments build on each other, use a continuous sequence and acknowledgment number space.
(a) Suppose you would like to access the website homepage. Draw a sequence diagram of the initial TCP connection setup. Assume your machine as the client chooses
sequence number 4200 and the website web server chooses 5600.
(b) Continuing on the diagram in a), draw another sequence diagram with the client sending a HTTP HEAD request to the web server, receiving the answer and closing the connection. Assume the HTTP request (header) size of 690 bytes and an HTTP response size of 330 bytes.
(c) Suppose you want to transmit 8100 bytes to the web server. Continuing with the sequence diagram you drew in a), draw another diagram to show the PP data transfer.
(d) Suppose the client wants to send 7 segments to the server but the 3rd segment gets lost. Briefly describe how the server will react. What does the client do to make sure the 3rd
segment is received by the server?
(e) Older TCP versions used a Stop-And-Wait1 mechanism rather than the Go-BackN2 mechanism. Suppose you would like to transmit an additional 2.5MB to the web server.
Assume that no packets are lost, no nodal processing delay occurs, no queueing delay occurs, and the RTT is 17 ms. How long would the transmission take using each of the mechanisms
(in seconds)? Are there any benefits in using a Stop-And-Wait mechanism? For this question,assume the TCP connection has already been established.
We keep in mind three styles of errors: • detail mismatch, as in [1,2,3] versus [1,9,3] or [1,2,3] versus [0,2,3] • left deletion, as in [1,3] as opposed to [1,2,3] or [1,2] versus [1,2,3] • proper deletion, as in [1,2,g3] versus [1,3] or [1,2,3] as opposed to [1,2] Write a function genEquals n xs ys that returns proper if the two lists xs and ys are equal with no greater than n mistakes, and in any other case fake. You might also expect that n is a non-poor integer. [8 marks] All ML code should be explained definitely and must be free of pointless complexity. 3 (TURN OVER) CST.2014.1.4 SECTION B 3 Object-Oriented Programming (a) (i) Explain the purpose of get right of entry to modifiers in OOP languages. [2 marks] (ii) Copy and complete the desk underneath to reveal the get entry to regulations for the four get admission to modifiers in Java. [2 marks] Access Modifier Defining elegance Class in equal package Subclass in one of a kind bundle Non-subclass in distinctive package (b) A Java game dressmaker desires to store all the sport possibilities (e.G., player name, screen size, music quantity, etc.) inside a custom Preference class. (i) Assuming every choice is saved as a completely unique String key mapping to a String cost, give a easy implementation of Preference that allows for efficaciously placing or updating preferences and retrieving formerly set ones. Your implementation should define an exception that is thrown whilst a preference secret is asked however not gift. [5 marks] (ii) It is critical that only one Preference item exists in a walking sport. Show how to practice get right of entry to modifiers and the Singleton design pattern to make sure this. Your implementation ought to lazily instantiate the item. Is it necessary to make your elegance very last or Cloneable? Explain your solution. [6 marks] (c) The clothier additionally implements other Singleton lessons in the sport and proposes to create a SingletonBase base magnificence from which all such instructions would inherit the singleton behaviour. By supplying example Java code, explain why this isn't possible. [5 marks] four CST.2014.1.Five 4 Object-Oriented Programming A Lecturer wishes to create a application that lists his college students looked after by the range of realistic assignments they have completed. The listing have to be finest variety of assignments first, sub-taken care of by means of call in lexicographical order (A to Z). A magnificence StudentInfo shops the call and range of assignments finished for a student. Amongst different techniques, it consists of a void setCompleted(int n) approach that lets in changes to the variety of completed assignments. (a) Provide a definition of StudentInfo with an equals() approach and a natural ordering that fits the given requirement.