In reviewing the solution using stack, this does not seem like DFS. We are adding adjacent nodes at each level to the stack and iterating over it - just like BFS. I understand that we used Queue in the BFS solution, but the fact remains that we are still adding nodes at each level first.
Also, how one would account for in-order, pre-order, or post-order traversal with this implementation? Maybe I am missing something here.
Thank you for taking the time to answer my question!
Type your question above this line.