Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,908 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,182 people online right now. Registration is fast and FREE... Join Now!




Understanding Hashing Tables

 
Reply to this topicStart new topic

Understanding Hashing Tables, Need Help to make sure that I get the concept

jadedjeanne
5 Jan, 2008 - 11:53 AM
Post #1

New D.I.C Head
*

Joined: 13 Jun, 2007
Posts: 22


My Contributions
Hi. I'm trying to make a report on hash tables. I've been reading stuff here and other stuff on the internet and it all seems to just fly over my head. I'm just trying to make sure that I understand the concept properly.

From what I'm getting so far, A hash is like a method of organizing data using a key generated from the data itself. The point of a hash is so that it'll be easy to look for the data when you need it. It that right?

An example that I can think of is like a student list in a school. When you enroll they assign you a student number and all of your information is stored next to that or into that container (name, age, course, etc). So student numbers are the hash keys in effect.

If the stuff above is correct then there are a few things that I'm not so sure about:

1. Is it still considered a hash if I assign the key myself? Like if I were to make a sample program for the report and make a list of 10 students and use 0001 to 0010 as the hash keys, would that still be a hash? Or do I have to make a function that comes up with keys for it to be a valid example?

2. Is there such a thing as multiple hashes? Like the way the first few digits of a student number have something to do with the year that you enrolled (e.g. 2007-0112)?

Is my understanding of the concept of hashing waaay off?

Would really appreciate any help at all. Thanks.
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Understanding Hashing Tables
5 Jan, 2008 - 12:10 PM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,351



Thanked: 51 times
Dream Kudos: 25
My Contributions
http://en.wikipedia.org/wiki/Hash_table

Take a quick look at some of the external references at the bottom of the Wiki article - they have some pretty good explanations.
User is online!Profile CardPM
+Quote Post

lockdown
RE: Understanding Hashing Tables
5 Jan, 2008 - 12:38 PM
Post #3

D.I.C Regular
Group Icon

Joined: 29 Sep, 2007
Posts: 376



Thanked: 1 times
Expert In: PC, Support

My Contributions
QUOTE(jadedjeanne @ 5 Jan, 2008 - 12:53 PM) *

Hi. I'm trying to make a report on hash tables. I've been reading stuff here and other stuff on the internet and it all seems to just fly over my head. I'm just trying to make sure that I understand the concept properly.

From what I'm getting so far, A hash is like a method of organizing data using a key generated from the data itself. The point of a hash is so that it'll be easy to look for the data when you need it. It that right?

An example that I can think of is like a student list in a school. When you enroll they assign you a student number and all of your information is stored next to that or into that container (name, age, course, etc). So student numbers are the hash keys in effect.

If the stuff above is correct then there are a few things that I'm not so sure about:

1. Is it still considered a hash if I assign the key myself? Like if I were to make a sample program for the report and make a list of 10 students and use 0001 to 0010 as the hash keys, would that still be a hash? Or do I have to make a function that comes up with keys for it to be a valid example?

2. Is there such a thing as multiple hashes? Like the way the first few digits of a student number have something to do with the year that you enrolled (e.g. 2007-0112)?

Is my understanding of the concept of hashing waaay off?

Would really appreciate any help at all. Thanks.


I had very similar problems understanding hashing when I was studying for my Security + certification. So for your first question you dont technically need to have a function that creates the hash keys for you. The reason you do normally have a function (or mathematical equation) is:
1. Computers are much faster and better hash keys
2. If you have a lot of data you want to work with having a simple equation will speed up the process of creating and assigning keys.

The way to look at it is, hashing is more of a method that is proven to work. Its like making cereal for break fest. Your parents tell you to put in your frosted flakes and then put in the milk. But you can still put in the milk first and then put in the frosted flakes. Its just a method of making your break fest and dose not mean you have to do it that exact way.

For your second question hashing can be as complex as you would like it to be. Now due to the length of a hash you might need to have two hashes to first represent the person year and then their students number. It really all depends on a couple factors of creating your hash.

The above link it a very good resource and trust me its not the more simple thing to understand. I would start by working with small amount of data and create simple applications. Start on the smaller scale to get the concept and then work your way up.

This post has been edited by lockdown: 5 Jan, 2008 - 12:40 PM
User is offlineProfile CardPM
+Quote Post

jadedjeanne
RE: Understanding Hashing Tables
5 Jan, 2008 - 12:56 PM
Post #4

New D.I.C Head
*

Joined: 13 Jun, 2007
Posts: 22


My Contributions
Okay. I think I'm getting it little by little. Just need to read more. biggrin.gif

After looking at that powerpoint presentation from the hashing tables wiki it seems a bit clearer. It's just extremely overwhelming trying to find a way to actually implement it. I mean it's one thing to understand what hashing is for or to even understand the difference between 0(1) and 0(N) but the thought that I would have to find a way to put it in a working C program is driving me bonkers. crazy.gif

But I guess it's best that become comfortable with the concept first before I start worrying about that. Thanks for the help!
User is offlineProfile CardPM
+Quote Post

lockdown
RE: Understanding Hashing Tables
5 Jan, 2008 - 01:18 PM
Post #5

D.I.C Regular
Group Icon

Joined: 29 Sep, 2007
Posts: 376



Thanked: 1 times
Expert In: PC, Support

My Contributions
QUOTE(jadedjeanne @ 5 Jan, 2008 - 01:56 PM) *

Okay. I think I'm getting it little by little. Just need to read more. biggrin.gif

After looking at that powerpoint presentation from the hashing tables wiki it seems a bit clearer. It's just extremely overwhelming trying to find a way to actually implement it. I mean it's one thing to understand what hashing is for or to even understand the difference between 0(1) and 0(N) but the thought that I would have to find a way to put it in a working C program is driving me bonkers. crazy.gif

But I guess it's best that become comfortable with the concept first before I start worrying about that. Thanks for the help!


The biggest thing I found when learning hashing just how complex it really is. But if you look at it the reason it is so hard to understand it is a security method and must be secure and complex. Once you have learned hashing I would suggest looking in the ciphers and encryption due to hashing being a large part of them. Its great backround knowledge to have and extremely important to creating secure storage methods. The coolest thing is developing your own algorithm for ciphers.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 01:32PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month