Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Need help with hash tables in my code

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Need help with hash tables in my code

    can some one tell me the difference between hash tables and linked list please. I am very confused


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Need help with hash tables in my code

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    And please don't post topics requesting help in the Member Introductions area. I moved the thread to a more appropriate sub-forum.

  3. #3
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Need help with hash tables in my code

    Quote Originally Posted by sarbu_192 View Post
    can some one tell me the difference between hash tables and linked list please. I am very confused
    At conceptual level (not strictly related to Java):

    A linked list is a data structure composed by N nodes where each node has a "pointer" to the next node (the last node has a "null" next). So there is a chain of nodes and you need to keep a pointer to the "head" of the list. If you want to find the n-th node, you have to scan the list node by node. Note that there is also the concept of "double" linked list. Here a node has 2 pointers: to the previous and to the next node.

    An hash table has a more complex structure. Firstly it has a list (generally an indexable list or array, never a "linked" list) that is known as the "buckets" list. Each bucket is a sort of container for more elements that share the same feature (in Java this "feature" is based on the hashCode() ). The main goal is to distribute elements among the buckets in an quite even way. Think to a big encyclopedia you can have at home, where each volume groups all words with the same initial. All words are distributed quite evenly. And you are very close to this.
    Under a "bucket" there is generally a linked list where each item has a key and a value. Once you find the right bucket, you need to scan this linked list to find the value by the key.
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

Similar Threads

  1. help with trace tables for loops
    By catisch in forum Object Oriented Programming
    Replies: 3
    Last Post: October 18th, 2013, 03:07 PM
  2. Hash Functions
    By Blueshark in forum Java Theory & Questions
    Replies: 3
    Last Post: July 2nd, 2012, 03:04 PM
  3. Problem with tables !
    By redpower1989 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 25th, 2011, 05:29 AM
  4. Data tables and such like.
    By ShaunB in forum Java Theory & Questions
    Replies: 1
    Last Post: December 30th, 2009, 06:10 PM
  5. Constructors, Hash Tables, & Linked Lists
    By illusion887 in forum Collections and Generics
    Replies: 2
    Last Post: December 3rd, 2009, 03:46 AM

Tags for this Thread