There are so many situations where you have one piece of information (key) and want a system to give you more information based on that key.
This is the need behind the evolution and implementation of several computing structures such as databases, binary trees, hash tables, and supporting algorithms.
Hash Tables have the following features:
This is the need behind the evolution and implementation of several computing structures such as databases, binary trees, hash tables, and supporting algorithms.
Hash Tables have the following features:
- They facilitate a quick and sometimes inexpensive way to retrieve information. They consume little CPU and if small-enough can fit in RAM. The speed is gained from the way the data location is calculated from the key, this is done in almost a linear fashion which outperforms other methods like binary search and linear search
- They can store information based on a key.
- They are language/technology independent. They don't require special hardware or software to implement them as the majority of programming languages would be sufficient to create the necessary algorithms for them.
- They have friendly interface - to get data, you pass a key and to store data, you pass a key in addition to the data.
- The theory allows the storage and retrieval of data based on numeric as well as non-numeric key values.
Hash tables are used in memory during the processing of a program (they can be persisted to disk but that is a different topic), some usages are : - Facilitation of Associative Arrays -
- Lookup values (states, provinces, etc.). You could load small amounts from database into hash tables for quick lookups (decoding an encoding of data) - This is of paramount effect in large batch jobs for Extract Load and Transform scenarios. It is also very valuable for data validation.
- Data Buffering. You could store frequently used data from a database in a hash table to facilitate quick access.
- Uniqueness Checking - You can use hash tables to ensure that no value is duplicate in a list.
- Keyword Recognition - In cases you want to identify if a given text has certain keywords in it or not, instead of checking the database with each value, you could use a hash table
- Decision tables - Large conditional flows may be stored in an array where given a condition id, you could retrieve and execute related code segments (this may be used in interpreted languages).
- Game programming could use Hash tables to keep track of player scores, weapons of a player, etc.