Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
abstract data structures
#9
Oh course, hashing uses duplicate keys, didn't think of that but again in reality the hash key is augmented by the data it is carrying with it.

That's only because there is a limited number of cells in the target array.

The way I always designed hash tables was:
  • 1st make sure the length of the hash table is a prime number. This only because it makes for very even distribution.   This length was chosen to be close to the number of items you expected to be in the table at any given time.
  • I didn't worry about using another cell in the table when a collision was encountered, what I did instead was to start a linked list moving laterally from the cell. Then you never had to reallocate the table itself, which is time consuming.
  • On lookup, if a collision was encountered, it would start a search in the linked list but it would rarely go more than a few nodes before a match was found. This never caused a bottleneck as you would be inclined to think, because the prime number length of the table led to very even distribution (in a large table).
I used this method on many large search algorithms with outstanding success. It is exactly the algorithm I
used for call record processing at LCI International (which became QWest, which is now Century Link).
Reply


Messages In This Thread
abstract data structures - by Skaperen - Apr-18-2017, 04:38 AM
RE: abstract data structures - by Larz60+ - Apr-18-2017, 08:36 AM
RE: abstract data structures - by Skaperen - Apr-19-2017, 02:56 AM
RE: abstract data structures - by volcano63 - Apr-18-2017, 08:48 AM
RE: abstract data structures - by wavic - Apr-18-2017, 10:41 AM
RE: abstract data structures - by ichabod801 - Apr-19-2017, 01:28 AM
RE: abstract data structures - by Skaperen - Apr-19-2017, 06:02 AM
RE: abstract data structures - by ichabod801 - Apr-19-2017, 06:34 AM
RE: abstract data structures - by Skaperen - Apr-19-2017, 09:34 AM
RE: abstract data structures - by Larz60+ - Apr-19-2017, 09:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Introducing scalaps: Scala-inspired data structures for Python matthagy 2 2,358 Mar-03-2019, 01:55 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020