Standard Bar Binary Trees · Traversals O(n) · O(n)
A night-shift courier audits a delivery franchise's hub-and-branch chart without a guide — no recursive dispatchers allowed after midnight. Armed with a clipboard stack of pending stops, he stamps a hub the moment he reaches it and jots its two branches as pending return addresses. By popping the left branch before the right, his stamp order mirrors the official root-first audit sheet.
Input: The root of a binary tree given as a level-order array where null marks a missing child.
Output: Return an array of node values in preorder, produced without recursion.
1 <= number of nodes <= 10^5-100 <= node value <= 100No recursive calls allowed — the traversal must run on an explicit stackInput: {"tree":[1,2,3,4,5,null,6]}
Output: [1,2,4,5,3,6]
Identical to recursive preorder: root, left wing, right wing.
Input: {"tree":[7]}
Output: [7]
One node, one stamp — the stack empties immediately after.