20172322 2018-2019-1 October 19 class test report
Program: Program design and data structure
Class: 1723
Name: Zhang Hao
Study No.: 20172322
Lab Teacher: Wang Zhiqiang teacher
Test Date: October 19, 2018
Compulsory/elective: compulsory
Supplementary exercises the original question
The number you want to find is in the initial order of 11,78,10,1,3,2,4,21
Problems with homework submitted in class
- The binary Lookup section of the ASL is calculated incorrectly.
- Hash lookup (linear) section of the storage structure error, ASL calculated wrong.
- Hash lookup (chain address) section of the storage structure error.
Corrective Scheme and analytical thinking
- Two-point Search
Sorted first, sorted in order: 1 2 3 4 10 11 21 78
into the array (assuming that the algorithm requires a smaller number first)
ASL = (1 + 22 + 34 + 4) * 1/8 = 21/8 = 2.375
- Hash lookup (linear)
n = 8, so the value of M should be between 8.8-13.6, this time select 11 as M.
,
Where 11,78,10 first entered No. 0, 1th, 10th position,
1 the need to put in conflict, so (+)/11 = 2, so 1 into the 2nd position.
3 put in the 3rd position,
2 need to put into conflict, so (/11=2) also have conflict, so (1+1+1)/11=3, so 2 into the 4th position,
4 need to put into conflict, so (4+1)/11=5,5 into the fifth position,
21 the need to put in a conflict, so 21 into the 6th position.
ASL = (1+1+2+1+3+2+1+8) * 1/8 = 2.375
- Hash lookup (chain address)
,
11,78,10 first into No. 0, 1th, 10th position,
1 need to put in conflict, it will be 1 into the chain of 78,
There is no conflict when 3,2,4 is placed,
21 into the conflict, it will be 21 into the chain after 10.
ASL = (81 + 22)/8 = 1.25
Feelings
- Binary lookup is not as simple as odd numbers for an even number of elements
- Sorting is not required for the storage of hash lookups !
20172322 2018-2019-1 October 19 class test report