Memory allocation for a tree and its subtree -


in linux system.

if have 2 binary trees, tree has millions of nodes, while tree b has few hundred nodes.

i want check if b subtree of a.

one solution thinking is, say, uses 50mb of memory, , addresses contiguous, while b uses 1kb. if b part of a, addresses of b subset of a's addresses (i guess?).

so can use tree a’s memory address range , b’s memory address range determine if b subtree of a?

update: think if using static memory allocation, , there 1 node refers same pointer root of b refers to, when find node, can determine b subtree of a.

you cannot use memory addresses of a , b check equality of a , b.

an alternative generate hash of b tree. depth first traversal of a, generating hash of subtrees of a. if hash of subtree of a matches hash of b, verify b matches particular a subtree.

see this generating hash tree.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -