A Merkle tree, also known as a binary hash tree, is a data structure used to efficiently summarize and verify the integrity of large data sets. Merkle trees are binary trees that contain cryptographic hashes.
Merkle trees are used in bitcoin and other blockchains to summarize all transactions in a block, producing a complete fingerprint of the entire set of transactions, providing a very efficient process to verify if a transaction is included in a block. A Merkle tree is built by running a hash function on pairs of nodes recursively until only a single hash remains, which is called a root or merkle root.
When N data elements are taken, each one of them is hashed and summarized in a merkle tree, it can be checked if any data element is included in the tree with a maximum of 2 * log 2 (N) calculations, making it a very efficient data structure.
In the case of the blockchain, the leaf nodes or nodes at the bottom are the transactions included in the block and the tree is generated upwards by applying the corresponding hash function.