Records are stored in a 2D hash table of 10 rows by 3 columns. The hash of a key is MOD(Key, 10) — that result is the row. If two keys hash to the same row, the later record uses the next free column in that row.
Empty slots store the key -1.
Write:
- function
Hash(Key) — return MOD(Key, 10)
- procedure
InsertData(Key, Data) — store the pair in the first empty column of the hashed row
- function
GetRecord(Key) — return the matching data, or "Not found"
The harness reads how many records to insert, then each key and its string, then how many lookups, then each lookup key.
Input: Insert count, key/data pairs, lookup count, then keys.
Output: One lookup result per line.
Example:
Input: 3
15
alpha
25
bravo
12
charlie
3
25
12
99
Output: bravo
charlie
Not found