Does binary tree efficient in solidity? iethereum/tron network

477 views Asked by At

Does storing/searching/writing binary tree is efficient enough from gas perspective? Let say I have node A. and new node B. node B should be placed at the first available place in the subtree starting from Node A. After that, we need traverse from node B to root node and update the count field for all nodes

Also, does any lib exist for such data structure?

1

There are 1 answers

0
Andelf On

You can use an array-like rep for Tree.

mapping(uint256 => bytes32) public tree;

FYI: https://github.com/tronprotocol/java-tron/blob/feature/shieldedUSDT/deploy/ShieldedTRC20.sol