Introduction to Merkle Tree

Merkle tree also known as hash tree is a data structure used for data verification and synchronization.
It is a tree data structure where each non-leaf node is a hash of it’s child nodes. All the leaf nodes are at the same depth and are as far left as possible.

It maintains data integrity and uses hash functions for this purpose.

Hash Functions:
So before understanding how Merkle trees work, we need to understand how hash functions work.
A hash function maps an input to a fixed output and this output is called hash.
The output is unique for every input and this enables fingerprinting of data.
So, huge amounts of data can be easily identified through their hash.

This is a binary merkel tree, the top hash is a hash of the entire tree.

For a Binary Merkel tree

Operation Complexity
Space O(n)
Searching O(logn)
Traversal O(n)
Insertion O(logn)
Deletion O(logn)
Synchronization O(logn)

Applications:




Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :