Rabu, 25 Maret 2020

Hashing Data Structure

Hashing Data Structure

Hashing is an important Data Structure which is designed to use a special function called the Hash function which is used to map a given value with a particular key for faster access of elements. The efficiency of mapping depends of the efficiency of the hash function used.
Let a hash function H(x) maps the value x at the index x%10 in an Array. For example if the list of values is [11,12,13,14,15] it will be stored at positions {1,2,3,4,5} in the array or Hash table respectively. 

struct DataItem {
   int data;
   int key;
};


BlockChain technology employs Hashing Algorithms as the building blocks to create secure Blocks of data.
In a overly simplified explination, it does this by asking the following question
Given a hashed output with some criteria, can you determine what input will generate that output? i.e. What input string, when passed through a hashing function (eg. SHA256), will generate an output string that ends in …..abc276
Given the nature of hashing algorithms (i.e. hashing algorithms are one-way), we know that to answer this question is difficult, and will possibly require brute force approach, which would translate to a great deal of computing power. After trying several million different combinations of inputs, finally one input string may generate an output string like ed892349837abd2349abc276, which will finally match the criteria.

Binary Tree Data Structure

A tree whose elements have at most 2 children is called a binary tree. Since each element in a binary tree can have only 2 children, we typically name them the left and right child.
A Binary Tree node contains following parts.
  • Data
  • Pointer to left child
  • Pointer to right child

  • struct node {
       int data;   
       struct node *leftChild;
       struct node *rightChild;
    };

    Tidak ada komentar:

    Posting Komentar

    Hashing Data Structure

    Hashing Data Structure Hashing is an important Data Structure which is designed to use a special function called the Hash function wh...