Separate chaining to resolve collisions

Posted on 2011-10-23
Last Modified: 2012-05-12
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)
Question by:gudni12345
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Sounds fun. Did you have a question?

    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.

    LVL 74

    Accepted Solution

    Hashing algorithms are not my forte, but according to , 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.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    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.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now