Question: In C, Write a program table that maintains and manipulates a hash table according to instructions provided in a le. table takes a single argument,

In C, Write a program table that maintains and manipulates a hash table according to instructions provided in a le. table takes a single argument, which is a path to the le containing the instructions. table uses a hash table with 10,000 buckets. It uses a very simple hash function: h(n) = n mod 10,000. To handle collisionswhen two dierent values hash to the same bucketeach bucket should contain a linked list of values. Thus, to determine whether a value n is present in the table, rst look up entry h(n) in the bucket array, then search the buckets list for n. The operations supported by table are: insert n Add an integer n to the hash table. If n is already present in the table, print duplicate. Otherwise, print inserted. search n Check whether n is present in the hash table. If it is, print present. Otherwise, print absent. Input format Each line of the input le contains an instruction. The line begins with a single character (either i or s), followed by a space and then an integer. The characters i and s indicate insert or search operations, respectively, and the integer represents n.

Output format - Normal output for table contain the results printed for each instruction, each on its own line. If the argument to table is a non-existent le, the output is the word error and nothing else.

Usage Assume a text le, file.txt, with the following content:

i 10

i 5

i 325689

s 5

i 5

s 100 With this assumption, $ ./table file.txt

inserted

inserted

inserted

present

duplicate

absent

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!