Solved

# Separate chaining to resolve collisions

Posted on 2011-10-23
242 Views
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)
0
Question by:gudni12345

LVL 74

Expert Comment

Sounds fun. Did you have a question?
0

Author Comment

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

LVL 74

Accepted Solution

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

## Featured Post

### Suggested Solutions

sameEnds challenge 3 85
sameEnds challenge 25 57
wordlen challenge 3 32
Problem to event 3 28
Prime numbers are natural numbers greater than 1 that have only two divisors (the number itself and 1). By “divisible” we mean dividend % divisor = 0 (% indicates MODULAR. It gives the reminder of a division operation). We’ll follow multiple approac…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.