-->
当前位置:首页 > 题库

PROGRAMMING:Linear rehashing of average search length

Luz5年前 (2021-05-10)题库500
For the integer array with the specified length of N, it is stored in the hash table with the specified length of M, using the specified hash function (using simple modulo prime P operation), if using linear rehashing (here refers to: find the next empty position in case of conflict) to deal with the conflict, the programming calculates the average search length when the search is successful and the average search length when the search fails.
###Input example:
Three integers in the first line represent the number of elements to be stored n, the length of hash table to be stored m and the prime number of hash function division P. The second line is n integers separated by spaces.
```in
9 13 11
47 7 29 11 9 84 54 20 30
```
###Output example:
Output the average length of successful search and the average length of failed search in two lines.
Note: Please express it in the form of total search length divided by total search times (for example: there are 10 successful searches, a total of 30, and the average successful search length is 30 / 10).
```out
23/9
41/11
```







answer:If there is no answer, please comment