> Aztec.nr API reference, v6.0.0 (mainnet and testnet). Index: https://docs.aztec.network/aztec-nr-api/v6.0.0/llms.txt

# Struct UnbalancedMerkleTree

Module: `noir_aztec::protocol::merkle_tree::unbalanced_merkle_tree`

```rust
pub struct UnbalancedMerkleTree {
    pub root: Field,
}
```

## Fields

```rust
root: Field
```

## Implementations

```rust
impl UnbalancedMerkleTree
```

Calculates the root of the minimal size merkle tree required to store `num_non_empty_leaves`.

Since we cannot isolate branches, it cost more gates than using MerkleTree on the full array of elements `N`, but it may be cheaper onchain when proving the membership of a leaf.

```rust
pub fn new_sha<let N: u32, let MAX_SUBTREES: u32>(
    leaves: [Field; N],
    num_non_empty_leaves: u32,
) -> Self
```

```rust
pub fn get_root(self) -> Field
```
