I have two different ways to traverse a tree adt that essentially do the same thing except one is a recursive function and the other is iterative. How could I compare the efficiency between them?
RECURSIVE
inorder(node)
if node.left ≠ null then inorder(node.left)
print node.value
if node.right ≠ null then
ITERATIVE
inorder(node)
while hasleftchild(node) do
node = node.left
do
visit(node)
if (hasrightchild(node)) then
node = node.right
while hasleftchild(node) do
node = node.left
else
while node.parent ≠ null and node == node.parent.right do
node = node.parent
node = node.parent
while node ≠ null