tags:

views:

42

answers:

1

I'm looking a data structure or algo (to be implemented in C) that will provide low time-complexity recursion from the deepest nodes to the shallowest nodes in a complex, nested structure.

The application is protocol encoding, where each element must know its size (the combined size of its data, and any member elements).

I've been banging my head against this one -- I really appreciate everyone's help.

+1  A: 

You can use a stack and push the pointer to the nodes as you encounter them
Finally you will have the deepest node at the top and you can go to the shallowest node by simply popping out the pointers from the stack.

Neeraj
That's what I was thinking about -- wasn't sure if there was a better way of doing it! Thanks for the prompt response :)