# How to calculate a root node in a Merkle Patricia tree?

I'm trying to understand a Merkle Patricia tree.
For example there are two accounts:
x00: {balance: 1}
x01: {balance: 2}

I can't understand how to begin building my trie. RLP and HP encoding are known, but what is the root node?

Let's take a pseudo-code example:

```x00: {balance: 1}
x01: {balance: 2}
x02: {balance: 3}
x03: {balance: 4}
```

You calculate the first-level nodes:

```hashOf("x00: {balance: 1}", "x01: {balance: 2}") -> node1 0x1234
hashOf("x02: {balance: 3}", "x04: {balance: 3}") -> node2 0x5476
```

You then calculate the second-level node(s):

```hashOf("node1 0x1234", "node2 0x5476") -> node3 0x3981
```

`node3`, with the value of `0x3981`, is your root node.

• Are sure you are explaining Merkle Patricia Tree? It looks like classic Merkle tree – Igor Barinov Oct 10 '16 at 22:57
• The pseudo-code I wrote describes both of them. A Patricia tree will provide storage savings because, unlike in my example, the address space of Ethereum's state is full of holes. – Xavier Leprêtre B9lab Oct 11 '16 at 10:08