You are here:

C++/C++ Hashing Table in Data Structure

Advertisement


Question
Hello,
I have some question to ask you regarding this question.

This is the question :

Write a program to perform hash table using two different hashing functions and two different resolution methods to solve the collision when happened. The record to be inserted in the hashing table, must be contains of at least 4 fields.

Can you please help me on how i should start. Actually, I understand the hashing function but I got stuck on how i should start to code this program.

The question ask to choose any methods of hashing and i intend to choose the simplest one first, which is the direct method. Then, i should have at least 4 field of records. Is it means that i will going to make an output file like the .txt in order to save the records? Or just by make it in array? And also, I will going to have a dynamic array or just a static array? Can you please guide me steps by steps what i should make first to code this program because it really make me stuck..

Your kindness is much appreciated..Thank you so much..

Answer
> Then, i should have at least 4 field of records.
> Is it means that i will going to make an output file like the .txt in order to save the records?
> Or just by make it in array?

To start with, just have a struct or class with four member variables to represent a record of four fields. Select one of them as the 'key' and write a hash function for that. The hash function would have to take into account the size of the array for the hash table.

> And also, I will going to have a dynamic array or just a static array?

Start with a simple static array; complete the rest of the code and make sure that it works correctly.
You can easily convert it to use a dynamic array, if it is required later.
The most commonly used hash table size is a prime number.

For more information and code fragments, see:
http://www.eternallyconfuzzled.com/tuts/datastructures/jsw_tut_hashtable.aspx  

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


vijayan

Expertise

my primary areas of interest are generic and template metaprogramming, STL, algorithms, design patterns and c++09. i would not answer questions about gui and web programming.

Experience

over 15 years

Education/Credentials
post graduate engineer

©2012 About.com, a part of The New York Times Company. All rights reserved.