Binary Tree, Data Structure Algorithm, Algorithms, Dotnet, Csharp.
stack.Push(root); while (stack.Count > 0) { // Get the current element in the stack TreeNode node = stack.Pop(); // Add the value of the popped node to the output list output.Add(node.val); // If the popped node has a right child, push it onto the stack if (node.right != null) {