<p>You can serialize a binary tree with <code>n</code> leafs (such as a merkle tree) as an array of <code>2n-1</code> entries. The root is entry 1 and for each node the left child is at position <code>2n</code> and the right child is at position <code>2n+1</code>. This gives you a compact representation of the entire tree.</p>

<p>Another option would be to just have the <code>n</code> leaf nodes in a list since the inner nodes are actually generated from the leafs.</p>

<p>Both need to be checked by a program, since checking the validity of a tree involves computing cryptographic hashes. Visualizing them in a human readable format does not really provide any security if it cannot be verified.</p>

CC BY-SA 3.0
2016-04-10T16:02:45.123Z
2016-04-10T16:02:45.123Z
cdecker
<p>Do you have any ideas or suggestions how to visualize Merkle trees? </p>

<p>For our open source project "Open Tracking" we create Merkle trees for thousands of tracking counters before putting the root hash to a bitcoin transaction with OP_RETURN script. </p>

<p>Each hour we merklize state of all active counters for ~20,000 domains and thus we have the tree with 20k elements at the base level. </p>

<p>My first idea was to visualize it in spreadsheet-style. A first column will be level one, a second column will be level two etc.</p>

CC BY-SA 3.0
2016-04-05T02:43:49.630Z
A Merkle tree is just hashes of hashes of hashes (etc.). What benefit is there to visualizing it?
Nayuki
CC BY-SA 3.0
2016-04-05T03:56:45.713Z
From the user side, there is a reason. He needs to check if the tree is composed of elements existed in a period when a transaction has been submitted to the blockchain. So, in the interface he press on the element and sees all the hashes of all nodes of the tree with hyperlinks to files. Thus, he can download all the files, calculate independently all those hashes and check that the record he is interested in not tampered.
Igor Barinov
CC BY-SA 3.0
2016-04-05T07:32:08.557Z
Isn't just the list of files relevant in the end? The rest of the Merkle tree can be generated from them directly. Else, you could just present each file with its [Merkle branch](http://bitcoin.stackexchange.com/q/42281/5406).
Murch
<merkle-tree>
Visualize Merkle tree
Igor Barinov
# Visualize Merkle tree

(Asked by: username_0 on 2016-04-05)

Do you have any ideas or suggestions how to visualize Merkle trees?

For our open source project "Open Tracking" we create Merkle trees for thousands of tracking counters before putting the root hash to a bitcoin transaction with OP\_RETURN script.

Each hour we merklize state of all active counters for ~20,000 domains and thus we have the tree with 20k elements at the base level.

My first idea was to visualize it in spreadsheet-style. A first column will be level one, a second column will be level two etc.

**Tags:** merkle-tree

> **Comments:**
> **username_1**: A Merkle tree is just hashes of hashes of hashes (etc.). What benefit is there to visualizing it?  
> **username_0**: From the user side, there is a reason. He needs to check if the tree is composed of elements existed in a period when a transaction has been submitted to the blockchain. So, in the interface he press on the element and sees all the hashes of all nodes of the tree with hyperlinks to files. Thus, he can download all the files, calculate independently all those hashes and check that the record he is interested in not tampered.  
> **username_2**: Isn't just the list of files relevant in the end? The rest of the Merkle tree can be generated from them directly. Else, you could just present each file with its [Merkle branch](http://bitcoin.stackexchange.com/q/42281/5406).  

---

## 1 answers

### Answer by username_3 on 2016-04-10. Score: 2

You can serialize a binary tree with `n` leafs (such as a merkle tree) as an array of `2n-1` entries. The root is entry 1 and for each node the left child is at position `2n` and the right child is at position `2n+1`. This gives you a compact representation of the entire tree.

Another option would be to just have the `n` leaf nodes in a list since the inner nodes are actually generated from the leafs.

Both need to be checked by a program, since checking the validity of a tree involves computing cryptographic hashes. Visualizing them in a human readable format does not really provide any security if it cannot be verified.


---

