Difference between revisions of "TADM2E 5.31"

From Algorithm Wiki
Jump to: navigation, search
(Recovering wiki)
 
(Undo revision 790 by EthanGamer (talk))
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
*For BFS, queues are used.
 
*For BFS, queues are used.
  
*For DFS, stacks are used. Normally in real implementation, we use recursion in place of an explicit stack.
+
*For DFS, stacks are used. The use of recursion is using the language-managed stack to store the intermediate state in place of an explicit stack. However since in practice the size of the stack is limited, robustness dictates to use an explicit stack for any real-world program that needs to deal with an unbounded maximum depth recursion.

Latest revision as of 13:37, 23 July 2020

  • For BFS, queues are used.
  • For DFS, stacks are used. The use of recursion is using the language-managed stack to store the intermediate state in place of an explicit stack. However since in practice the size of the stack is limited, robustness dictates to use an explicit stack for any real-world program that needs to deal with an unbounded maximum depth recursion.