Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Story plot: tall, square, symmetric. For each technique, give the relevant matrix equations to obtain the solution x, and point out the properties of the

Story plot: 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 Xk 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, . . . , xn1 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.82 SECTION D.

Specifically they want room temperature to be reliably sensed 1299,999% of the time, to be able to detect faulty components (temperature sensors, AC, Furnace) within 1 minute and detect temperature changes from any sensor within 20 seconds. Two major activities of the software design process include Software Architecture and Detailed Design. Demonstrate on how these two activities being executed? (1) Do you design software when you "write" a program? What makes software design different from coding? (2.1) What is the goal of software design? What would be different if developers went straight to coding without adhering to software design principles?Demonstrate on how these two activities being executed? Explain the difference between 'y' and "xy" when used as constants in C. Describe the memory representation of both values. [4 marks] (b) Consider the following C program: void swap(int x, int y) { int temp = x; x = y; y = temp; } int main(int argc, char **argv) { int x = 0; int y = 1; swap(x, y); assert(x == 1); return 0; } Briefly explain the role of the assert statement and why this program will trigger an assert failure when executed. Supply two modified versions of the program that alter the swap function definition and, if necessary, its calls, to avoid this assert failure. One version should be in C, and the other should use C++ language features. [4 marks] (c) Describe the address-space layout (highlighting four areas of memory) of a typical compiled x86 C program, and how each of these areas are used by C constructs. [8 marks]

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 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: [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.

Set the new range (range G6:K18) as the print area. (Hint: Page Layout->Print Area->Set Print Area) Go to the Clients worksheet, which includes a table named Clients. CTC Casualty Insurance provides a discount of $10.00 per month for clients who bundle their insurance by buying more than one type of policy, such as auto and homeowners insurance. Alex wants to display the monthly payment amount, including the discount as appropriate, in the Payment column. Provide this information for Alex as follows using an IF function and structured references: In cell H4, a formula using the IF function that tests whether the value in the Bundled column ([@[Bundled?]]) is "Yes". If the value in the Bundled column is Yes, subtract 10 from the amount in the Per Month column ([@[Per Month]]). Otherwise, the payment is the same as the value in the Per Month column. If necessary, fill the formula to the range H5:H48. Add a Total Row to the Clients table, which automatically totals the amounts in the Payment column. In cell B49, use the total row to display the count of the clients. Alex has an area in the range J3:K8 for looking up data in the Clients table. First, he wants to find the name of the client by looking up the client ID. He has already entered the client ID in cell K3. Look up the client name by using a VLOOKUP function. In cel K4, begin to enter a formula using the VLOOKUP function. Use the Client ID in K3 as the value to look up. Use a structured reference to the Clients table as the table to search (Table_array). Specify an exact match (FALSE) for the range lookup. Alex also needs to find the policy for the Client ID entered in cell K3. Look up the policy as follows: In cell J6, below the "Policy text, begin to enter a formula using the VLOOKUP function to determine the policy The formula should look up the Client ID and return the value in the Policy column of the Clients table, using a structured reference to the table. Specify an exact match (FALSE) for the range lookup. The third calculation Alex wants to make is to determine the total payments for the policy of the client he is looking up, which now appears in cell J6. Calculate the total payments for a policy as follows: In cell K7, begin to enter a formula using the DSUM function. Use structured references to the [#Headers] and [#Data] in the Clients table to specify the formula database. Use a structured reference to the Payment field header to specify the field to summarize. Use the values in the range J5:J6 as the criteria. Alex also wants to identify the number of a policies he has sold of a specified type. Calculate this information as follows: In cell K8, begin to enter a formula using the DCOUNTA function. Based on the headers and data in the Clients table, and using structured references, count the number of values in the Policy Type column that match the criteria in the range J5:J6.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

This is a multipart question covering various topics from mathematics computer science software design and algorithms Lets address each part in turn Matrix Equations and Properties Part a Story Plot t... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Applied Linear Algebra

Authors: Peter J. Olver, Cheri Shakiban

1st edition

131473824, 978-0131473829

More Books

Students also viewed these Programming questions

Question

Porters Five Forces of zillow and Redfin companies

Answered: 1 week ago