Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A simple hash table can be implemented, for integers, as an array (not vector) of linked lists. For a simple hash function, we can use

A simple hash table can be implemented, for integers, as an array (not vector) of linked lists. For a simple hash function, we can use the modulo to find the "hash" value of an integer. Specifically, if we have a 10 element array, and want to store the value 103, we would store it in position 3 (103%10=3). If we had a 15 element array, that same value would hash to 13 (103%15=13). Since multiple values can "hash" to the same location (collision), we use the linked list to resolve collisions (separate chain hashing).

A good start is to have an array size of 5, but to double the size of the array (and rehash all of the values, of course) when the array gets more than 80% full (so the first resize will happen after 5 inserts).

Please implement the following: The IntHasher class which contains, at least, the following o Insert (add an int to the table) o Remove (take an int out of the table; do nothing if it doesn't exist) o Find (return true or false if it exists) An output operator which prints ALL of the values in the hash table (order doesn't matter), one per line An addition operator which allows for the combination of two intHasher objects.

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

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions