Hashing Table and Binary Tree



HASHING TABLE AND BINARY TREE

Hash Table
Hash table is a data structure that stores data in an array format, where each data has a unique index value. With hashing, access to data will become faster.
Hash Function
Syntax of hash table:
struct DataItem {
   int data;
   int key;
};
Hash methods:

int hashCode(int key){
   return key % SIZE;
}


Binary Tree
A binary tree is a tree whose elements have maximal 2 children. The binary tree contains:
1. Data
2. Pointer of the left child
3. Pointer of the right child
tree
      ----
       j    <-- root
     /   \
    f      k  
  /   \      \
 a     h      z    <-- leaves 
Syntax of a binary tree:
struct node 
{
  int data;
  struct node *left;
  struct node *right;
};





Comments