Question
Given an ordered sequence, you are required to create an open-addressed Hash table, then do searching on it. We search for some numbers in it.
Given an ordered sequence, you are required to create an open-addressed Hash table, then do searching on it. We search for some numbers in it. Some may be found(success), and some maybe not be found(unsuccess). You are required to determine Average Searching Length(ASL) for success searching and unsuccess searching based on the searching results: ASLsucc and ASLunsuc。 The data set maybe is as big as 10000. First, you should input the data into an array and determine the input data number(n), take alpha(α load factor)as 0.8, then get len=n/α. Take the smallest prime number which is greater than len as the length(m) of the hash table. Hash Function set as follows: Hash(key)=key % m; We use linear probing to overcome collision: hask(key, i) = [hash(key) + i ] % m where i=0~1-m.
Input
The first line enters several positive numbers (in ascending order), ending with -1. The second line enters several search numbers ended with -1.
Output
output two doubles in one line with 2 fraction points separated by one space. The first one is ASLsucc, the second one is ASLunsucc.
Examples
input
18 13 36 15 42 10 3 5 9 12 8 28 21 25 30 31 45 23 19 11 -1
16 11 15 30 31 28 41 39 32 -1
output
2.20 3.75
input
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 -1
1 2 13 22 28 30 -1
output
1.00 1.00
Step by Step Solution
3.45 Rating (145 Votes )
There are 3 Steps involved in it
Step: 1
Answers include include define SIZE 13 define EMPTY 999999 empty condition define DELETE 9999999 delete condition int hashfunctionint the hash function to calucate the position of data int offsetint t...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started