Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5. THE THIRD PART: THE R1 SEARCH ALGORITHM In this next scenario, inspired by RAID 1, we will just duplicate all the given data using

image text in transcribed
5. THE THIRD PART: THE R1 SEARCH ALGORITHM In this next scenario, inspired by RAID 1, we will just duplicate all the given data using hashing. Given an array A of non-negative integers of length N, a second array B of length N is created: for each element i of A, the value A[i] is hashed to give an index j of B, and the value A[i] is stored in B[J]. For the hashing function, given constants as B and b, for each 1 , the value A [1] is hashed by the function (aA[i]+b ) mod N, which is equal to the index of B into which we store 1 . The following example demonstrates this: In this example the hash function is (3A[1]+1) mod 4 . For instance, the value 5 stored at index 1 in A is hashed to the value (35+1) mod 4=0, and thus 5 is stored at B[]. In this example there were no collisions in the hashed values since all values in A are distinct. For this task we assume there are no repeated values in A, and a hash function is chosen so there are no collisions for distinct values. To look for errors we hash all the values in array A to see if there is a match in the corresponding element of array B. If there is a mismatch between the two elements then an error is returned; if no errors are found, if a value is found then its index in A is returned. Task 4: Complete the following: 1. Write a pseudocode function R1(key, a, b, A, B, N) that takes non-negative integers key, a and b where a and b come from to the hashing function used to store indices in B; the arrays A and B of length N are also inputs: the function should return an index I where the value key is stored in array A if found; it should return 1 if the value cannot be found; otherwise it should return 2 if there was an error in the data storage, i.e. one of the values was altered unintentionally in at most one of the arrays. [8 marks] 2. Briefly explain how the method above could be adapted to allow for repeated integers in array A. [6 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

Advances In Databases And Information Systems Second East European Symposium Adbis 98 Poznan Poland September 1998 Proceedings Lncs 1475

Authors: Witold Litwin ,Tadeusz Morzy ,Gottfried Vossen

1st Edition

3540649247, 978-3540649243

More Books

Students also viewed these Databases questions