- Push the root node onto a Stack.
- Pop a node from the stack and examine it.
- If the element sought is found in this node, quit the search and return a result.
- Otherwise push all its successors (child nodes) that have not yet been discovered onto the stack. ( *Push Right first then Left )
- If the stack is empty, every node in the tree has been examined – quit the search and return "not found".
- If the stack is not empty, repeat from Step 2.
No comments:
Post a Comment