Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 a> and b, for each 1 , the value A[1] is hashed by the function (aA[1]+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[i]+1)mod4. For instance, the value 5 stored at index 1 in A is hashed to the value (35+1) mod 4=8, 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_2

Step: 3

blur-text-image_3

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

Respond to differences in values among people.

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Draft a business plan.

Answered: 1 week ago

Question

Describe the guidelines for appropriate use of the direct plan.

Answered: 1 week ago