Hash Table and Binary Search Tree

Hash table is a structure data which consist of table and function aiming to map unique key value from each record to hash, the record location is located within the table.

Hash Operation consist of :

Insert : Insert a value into the table
Find : Search a value in the table
Remove : Delete a value in the table
GetIterator : Return Iterator which check all value one by one.

The hash table uses an associative array data structure that associates a record with a unique key field in the form of a number (Hash) which is a representation of that record. For example, there is data in the form of a string to be stored in a hash table. The string is represented in a key field K.

The way to get this key field varies greatly, but the end result is a hash number that is used to determine the location of a record. This hash number is entered into the hash function and produces a record location index in the table.
             k (x) = key field generator function (1)
             h (x) = hash function (2)

Question : Does Blockchain technology employ hash table?

The answer is Yes as explained by the picture below, hash function connect the keys with the bucket.


Binary Search Tree

Binary Search Tree (BST) is a node-based binary tree data structure which has the following properties:
  • The left subtree of a node contains only nodes with keys lesser than the node’s key.
  • The right subtree of a node contains only nodes with keys greater than the node’s key.
  • The left and right subtree each must also be a binary search tree.
Binary Search Tree Example :



Comments

Popular posts from this blog

Push Linked List