I want to store data in hierarchical format like /a/b/c.
Insertion operations are
insert /a/b/c/d1 20 (where 20 is size of d1)
insert /a/b/c/d2 30 (where 30 is size of d2)
insert /a/b/c 50 (where 50 is size of c itself)
insert /a/b/x 40 (where 40 is size of x)
Retrieval operations are
Get size of /a/b/c should return 100 (20+30+50).
Get Size of /a/b should return 140 (20+30+50+40 size of all children)
It will better if it can be implemented in java
You could use a HashMap, as follows: