635592013-python
635592013-python
Transaction file
My solution:
Departmen
Key Name
t
077654 Eve Lindens CIS
093245 Sophie Grands BUS
114237 Ted White MTH
123453 John Adam CIS
156734 Jimmy Lions ENG
256743 Eva Lindens ENG
423458 Bob Bauer ECO
P 13-3.A hash file uses a modulo division method with 41 as the divisor. What is the address for
each of the following keys? a. 14232 b. 12560 c. 13450 d. 15341
My solution:
To find the address for each key using modulo division method, we need to divide the key by the
divisor (41) and take the remainder. The remainder will be the address for the key.
a. 14232 % 41 = 5 The address for key 14232 is 5 + 1 = 6.
b. 12560 % 41 = 14 The address for key 12560 is 14 + 1 = 15.
c. 13450 % 41 = 2 The address for key 13450 is 2 + 1 = 3.
d. 15341 % 41 = 7 The address for key 15341 is 7 +1 = 8.
P13-4.In the midsquare hashing method, the key is squared and the address is selected from the
middle of the result. Use this method to select the address from each of the following keys. Use
digits 3 and 4, counting from the left. a. 142 b. 125 c. 134 d. 153
My solution:
To use the midsquare hashing method to select the address from each key, we need to follow these
steps: Square the key. Extract the middle two digits from the squared value. Use the extracted
digits as the address.
a. 142 squared is 20164. The middle two digits are 16, so the address for key 142 is 01.
b. 125 squared is 15625. The middle two digits are 56, so the address for key 125 is 56.
c. 134 squared is 17956. The middle two digits are 95, so the address for key 134 is 79.
d. 153 squared is 23409. The middle two digits are 34, so the address for key 153 is 34.
13-7. Find the address of the following keys using the modulo division method and a file of size
411. If there is a collision, use open addressing to resolve it. Draw a figure to show the position of
the records. a. 10278 b. 08222 c. 20553 d. 17256
My solution:
To use the modulo division method, we divide the key by the file size and take the remainder as the
address. If there is a collision, we can use open addressing to find the next available slot. Let's
assume we have a file of size 411.
a. Key 10278: Address = 10278 % 411 = 3 There is no collision, so we can store the record at
address 3 + 1 = 4.
b. Key 08222: Address = 08222 % 411 = 2There is no collision, so we can store the record at
address 2 + 1 = 3
c. Key 20553: Address = 20553 % 411 = 2 There is collision, so we can store the record at address
3+1+1=5
d. Key 17256: Address = 17256 % 411 = 405 There is a no collision, so we can store the record at
address 405 + 1 = 406.