Separate chaining to resolve collisions

I neew to write a C++ program that inserts N random integers into
a table of size N=100 using separate chaining to resolve collisions, and
then nds and prints the length of the shortest and longest lists for
N = 10 3 (in power of three)
gudni12345Asked:
Who is Participating?
 
käµfm³d 👽Connect With a Mentor Commented:
Hashing algorithms are not my forte, but according to http://www.brpreiss.com/books/opus5/html/page225.html , separate chaining involves creating a linked list, which I assume you've studied prior to this point, for each slot in the hash table and inserting collisions into the linked lists. When you are done with your inserts, printing the length of the longest and shortest would be a matter of iterating over each linked list in the hash table, checking for the shortest and longest lists. It may be simpler to keep two separate variables which track the current longest and shortest lists. In this manner, you wouldn't have to iterate over the whole hash later. This is up to you, though.
0
 
käµfm³d 👽Commented:
Sounds fun. Did you have a question?
0
 
gudni12345Author Commented:
Sorry!!.The question is how.  I do know how to insert the random numbers in to af table but how to  use separate chaining to resolve collisions, and then find and prints the length of the shortest and longest lists., that is a mistery for me.

Hilsen
G.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.