Results 1 to 9 of 9

Thread: What is a hash table? [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    210

    What is a hash table? [RESOLVED]

    I've got a question. What is a hash table? I tried looking for the term in my VB.NET book (learn vb.net in 21 days) but it doesn't have anything on hash tables.
    Last edited by ultimate_girl; May 24th, 2005 at 05:26 AM.

  2. #2
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: What is a hash table?

    A hash table is a powerful data storage structure. Essentially it provies a key value pair. In VB.Net an example would be as follows

    VB Code:
    1. Public Sub HashTableTest()
    2.   DIM hash AS new hashtable()
    3.   hash.add("somekey", "somevalue") 'Note key and value can be any object, here they are strings
    4.   IF hash.containskey("somekey") Then Console.writeline(CStr(hash("somekey")))
    5.  
    6. End Sub

    It is a powerful data storage technique and I would highly recommend using them in the appropriate situation.

  3. #3
    Frenzied Member FishGuy's Avatar
    Join Date
    Mar 2005
    Location
    Bradford UK
    Posts
    1,708

    Re: What is a hash table?

    Hash tables are good for storing data for quick retrieval. The problem is you have no choice in the way data is stored i.e the sort order, because of the hashing algorithm used. For this reason retreiving and sorting data from a hash table is too problematic.

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: What is a hash table?

    Can't remember where I saw it now but "Bubble-Up List" is also interesting. Commonly used items are brought up near the front of the list and rarely used ones make their way to the end. Speeds up search times no end and it also (partially) efficiently stores the items in a sensible sequence. Probably not compatible with most situations where a hashtable would be used though
    I don't live here any more.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    210

    Re: What is a hash table?

    Quote Originally Posted by The_Duck
    A hash table is a powerful data storage structure. Essentially it provies a key value pair. In VB.Net an example would be as follows

    VB Code:
    1. Public Sub HashTableTest()
    2.   DIM hash AS new hashtable()
    3.   hash.add("somekey", "somevalue") 'Note key and value can be any object, here they are strings
    4.   IF hash.containskey("somekey") Then Console.writeline(CStr(hash("somekey")))
    5.  
    6. End Sub

    It is a powerful data storage technique and I would highly recommend using them in the appropriate situation.
    when is an appropriate situation?

  6. #6
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: What is a hash table?

    You would generally use a hashtable where you have a 1-x relationship with your key and value, ie your key will always define a single object (keys in a hashtable need to be unique).

    We could envisage a situation where you have say 10 student ID's

    1, 2, ... 10

    These ID's are unique. Each student could also have details stored about them, such as name, address etc.

    Thus we could define a structure

    Public Structure StudentInfo
    DIm name as string
    Dim address as string
    Dim x as etc
    End Structure

    We can then use a hashtable to store the details on all our strudents. Thus to get a particualr students name (from ID) we would call

    DirectCast(hash(SomeStudentID), StudentInfo).Name

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 2005
    Posts
    210

    Re: What is a hash table?

    thanks guys! =) now how do i rename this thing to "RESOLVED"?

  8. #8
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: What is a hash table?

    Edit your first post

  9. #9
    Frenzied Member Zakary's Avatar
    Join Date
    Mar 2005
    Location
    Canada, Quebec, Montreal
    Posts
    1,654

    Re: What is a hash table? [RESOLVED]

    As i understant HashTable and Array look to be similar ..... No ?
    Using VS 2010 on Fw4.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width