.NET Performance: Deep Recursion vs Queue
Posted
by
JeffN825
on Stack Overflow
See other posts from Stack Overflow
or by JeffN825
Published on 2011-01-16T00:49:48Z
Indexed on
2011/01/16
0:53 UTC
Read the original article
Hit count: 221
I'm writing a component that needs to walk large object graphs, sometimes 20-30 levels deep.
What is the most performant way of walking the graph?
A. Enqueueing "steps" so as to avoid deep recursion
or
B. A DFS (depth first search) which may step many levels deep and have a "deep" stack trace at times.
I guess the question I'm asking is: Is there a performance hit in .NET for doing a DFS that causes a "deep" stack trace? If so, what is the hit? And would I better better off with some BFS by means of queueing up steps that would have been handled recursively in a DFS?
Sorry if I'm being unclear. Thanks.
© Stack Overflow or respective owner