Your hashtable should have the following properties:
res = (key[0]-'a')+(key[1]-'a')*13+...+(key[n]-'a')*13**n
(** inidcates 13 raised to the nth power; this is not an operator in C). (You will probably want to use a long integer in your hashing function.) There are better, more complex, hashing algorithms. This one is sufficient.
put aaa 6
put bbbbcd 12
get aaa 5
rem aaa 5
get aaa 7
where:
hhtt 97 < htcommands.txt
put dfsdfs 7
put dklsjfds 20
put d 234
put ff 345
put ee 456
put ff 567
put gg 678
put hh 789
put ii 890
put jj 990
put kk 901
put mm 012
get ee 1
get ff 1
get mm 1
get dfsdfs 1
rem ff 1
rem kk 1
get mm
put ff 1024
put gg 2048
put zzz 4096
and here is a trace output from that input. Note that I made a very small hashtable and got it quite full. This was intentional as only be being pretty full can you really test probing. (You do not need to have the same output, and indeed I encourage you to innovate as there are many ways in the output could be clearer.)
[gtowell@powerpuff HW4a]$ cat inp.txt | ht 13
PUT 8 8
PUT 8 9
PUT 6 6
PUT 8 10
PUT 7 7
PUT 8 10
PUT 9 11
PUT 10 12
PUT 11 0
PUT 12 1
PUT 0 2
PUT 2 3
GET ee 456
GET ff 567
GET mm 12
GET dfsdfs 7
REM ff 1
REM kk 1
GET mm 12
PUT 8 10
PUT 9 11
PUT 2 2
The Hashtable
=============
0 ii 890
1 jj 990
2 zzz 4096
3 mm 12
4 0
5 0
6 d 234
7 ee 456
8 dfsdfs 7
9 dklsjfds 20
10 ff 1024
11 gg 2048
12 hh 789
/home/gtowell/bin/submit -c 246 -p 4 -d a4This will package up everything in the directory a4 and submit it under your login name along with a timestamp of your submission date.