Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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;

image text in transcribed
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[2j]+A[2j+1]. This works straightforwardly if N is even. If N is odd then the final element of B just stores A[N1] as we can see in the figure below: 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 mariss] 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

Step: 1

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

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions