• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hash Table and sorting data items  RSS feed

 
Aron Silvester
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hash tables are data structures that attempt to increase the efficiency of sorting data items? I say true, what do you think?

CROSS POST HERE: Hash Table and sorting data items
 
Les Morgan
Rancher
Posts: 779
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hash tables--or any hash function--is for grouping. You are not guaranteed a sort, but you are guaranteed a grouping according to your hash function.

ex: you have a hash function that says add the first 2 digits of a number together to get the hash--so numbers starting with "01" and "10" hash to the same grouping, but you cannot, at least IMO, say they are sorted.
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hash table and other has algorithms is working on hashing algorithm. To perform them right we need to choose hash code wisely otherwise it gives poor performance.

The worst case is O(n) when all the elements are in same bucket.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope. Hash tables aren't for sorting.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!