Question: Kindly provide solution for Task 3 only . The function CreateB creates this second array using a function call to Sum. For the algorithm CreateB
Kindly provide solution for Task 3 only.

The function CreateB creates this second array using a function call to Sum. For the algorithm CreateB address the following: 1. Explain very briefly in words why the best-case inputs and the worst-case inputs are the same for CreateB. Recall that there are two inputs to CreateB. [6 marks] 2. Use the Master Theorem and to derive the Theta notation for both the worst-case and best-case running times (or execution time) T(N), and show your working and reasoning. [10 marks) Building on the above, in a new scenario, given an array A of non-negative integers of length N, additionally a second array B is created; each element B[j] stores the value A[2*j]+A[2*j+1]. This works straightforwardly if N is even. If Nis odd then the final element of B just stores A[N-1] as we can see in the figure below: A: 7 5 6 3 2 1 4 8 9 1 2 3 4 5 6 7 8 B: 129 3 129 0 1 2 3 4 The second array B is now introducing redundancy, which allows us to detect if there has been a hardware failure: in our setup, such a failure will mean the values in the arrays are altered unintentionally. The hope is that if there is an error in A which changes the integer values then the sums in B are no longer correct and the algorithm says there has been an error; if there were an error in B the values would hopefully be incorrect From now on in this assignment we will assume that at most one array might have its values altered, but we do not know which one ahead of time. The goal is now to write an algorithm to search for a non-negative integer in the array A, but also to check for errors in the arrays. If there has been an error determined from checking both A and B, and an appropriate error value should be returned. If no errors are detected then we determine if the integer is in A or not. Task 3: Complete the following: 1. Write a pseudocode function R2 (key, A, B, N) that takes a non-negative integer key, and arrays A and B, as well as the length of A,N: the function should return -2 if the values in B do not correspond to the sums of values in A; if no error has been found the function should return the index if key is found in A, or -1 if key has not been found. [8 marks] 2. The Theta notation derive the worst-case running time T(N) of the algorithm R2. Describe the steps taken in your reasoning about what is the worst-case input and the resulting worst-case running time. [6 marks] 3. Very briefly explain why not all errors that can occur for array A will be detected in the method above. [4 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
