Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago