Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN C++ Closed Hash Table Assume that in the input file a3.txt, there are no more than 50 state names. Each entry is less than
IN C++
Closed Hash Table Assume that in the input file a3.txt, there are no more than 50 state names. Each entry is less than or equal to 15 chars; if any entry is more than 15 chars, take the first 15 chars. The data format is as follows: a b c NewYork Michigan Ohio where a, b, c are integers. Part 1. Closed Hash: You are to construct a closed hash table of total capacity ClosedHashB In step 1, define B as 60. Use linear rehash (one step increment) with the following hash function to insert each string inString from the input in a3.txt into the hash table: h(inString)(ainString[0] + b inString[l inSing[2]) mod ClosedHashB Note: the corresponding ASCII value will be taken for inString]. Alter it to uppercase if there is a ower case char (1) Record the cumulative number of steps (i.e., the number of hash table slots examined for available slot) for every string entered; this number must be printed immediately following each state name in the table. Use 2 chars for this mumber. Print the resulted hash table on the screen: 4 states each line; if the bucket entry is NULL, print a number of spaces that are assigned for each state. Enumerate each line with the first entry of the for. Each entry should be printed as 15 chars, followed by 2 char spaces for the cumulative number. For a name less than 15 chars, use spaces to make up (2) Search for each and every one of the entry in a4.txt in the table built in (1). Accumulate the number of comparisons in order to find the names. Divide that mumber by the total number of names, so you will get the average of comparisons required to search for a name in the table in (1). Part 2. Repeat Part 1, with ClosedHashB being 120 Part 3. Repeat Part 1 with rehash using quadratic probing, with ClosedHashB as 60 Part 4. Repeat Part 3 with ClosedHashB as 120 Both functions must be within a single program The output for closed hash table should be printed first, and wait for a keyboard input before the hash table being printed. All outputs are standard on the screen. Part 5: Summary: Input the results from Steps 1 to 4 into a table with rows for rehash (linear and quadratic) and columns for sizes of ClosedHashB (60, 120). Table entries are averages of search/found Closed Hash Table Assume that in the input file a3.txt, there are no more than 50 state names. Each entry is less than or equal to 15 chars; if any entry is more than 15 chars, take the first 15 chars. The data format is as follows: a b c NewYork Michigan Ohio where a, b, c are integers. Part 1. Closed Hash: You are to construct a closed hash table of total capacity ClosedHashB In step 1, define B as 60. Use linear rehash (one step increment) with the following hash function to insert each string inString from the input in a3.txt into the hash table: h(inString)(ainString[0] + b inString[l inSing[2]) mod ClosedHashB Note: the corresponding ASCII value will be taken for inString]. Alter it to uppercase if there is a ower case char (1) Record the cumulative number of steps (i.e., the number of hash table slots examined for available slot) for every string entered; this number must be printed immediately following each state name in the table. Use 2 chars for this mumber. Print the resulted hash table on the screen: 4 states each line; if the bucket entry is NULL, print a number of spaces that are assigned for each state. Enumerate each line with the first entry of the for. Each entry should be printed as 15 chars, followed by 2 char spaces for the cumulative number. For a name less than 15 chars, use spaces to make up (2) Search for each and every one of the entry in a4.txt in the table built in (1). Accumulate the number of comparisons in order to find the names. Divide that mumber by the total number of names, so you will get the average of comparisons required to search for a name in the table in (1). Part 2. Repeat Part 1, with ClosedHashB being 120 Part 3. Repeat Part 1 with rehash using quadratic probing, with ClosedHashB as 60 Part 4. Repeat Part 3 with ClosedHashB as 120 Both functions must be within a single program The output for closed hash table should be printed first, and wait for a keyboard input before the hash table being printed. All outputs are standard on the screen. Part 5: Summary: Input the results from Steps 1 to 4 into a table with rows for rehash (linear and quadratic) and columns for sizes of ClosedHashB (60, 120). Table entries are averages of search/foundStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started