View
234
Download
3
Tags:
Embed Size (px)
Citation preview
Tree TraversalTree Traversal
Traversal AlgorithmsTraversal Algorithms
• preorder• inorder• postorder
PreOrder TraversalPreOrder Traversal
Inorder TraversalInorder Traversal
Postorder TraversalPostorder Traversal
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output:
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a
for each of {b, c, d}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a
for each of {b, c, d}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b
for each of {e, f}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b
for each of {e, f}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e
for each of {j, k}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e
for each of {j, k}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j
for each of {}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j
for each of {j, k}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k
for each of {n, o, p}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k
for each of {n, o, p}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n
for each of {}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n
for each of {n, o, p}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o
for each of {}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o
for each of {n, o, p}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p
for each of {}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p
for each of {n, o, p}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p
for each of {j, k}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p
for each of {e, f}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p f
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p f
for each of {}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p f
for each of {e, f}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p f
for each of {b, c, d}
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
In which order does a preorder traversal visit the vertices in this ordered rooted tree?
procedure preorder(T: ordered rooted tree)r := root of Tlist rfor each child c of r from left to rightbegin T(c) := subtree with c as its root preorder(T(c))end
output: a b e j k n o p f c d g l m h i
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output:
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output:
callstack
r = a, l = ?s = {}
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output:
r = a, l = bs = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output:
r = a, l = bs = {}
r = b, l = ?s = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output:
r = a, l = bs = {}
r = b, l = es = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output:
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = ?s = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {}
r = j, l = ?s = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e
r = a, l = bs = {}
r = b, l = es = {}
r =e, l = js = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ?s = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ns = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ns = {}
callstack
r = n, l = ?s = {}
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ns = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ns = {o,p}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ns = {o,p}
callstack
r = o, l = ?s = {}
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ns = {o,p}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ns = {o,p}
callstack
r = k, l = ?s = {}
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
r = k, l = ns = {o,p}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p
r = a, l = bs = {}
r = b, l = es = {}
r = e, l = js = {k}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p b
r = a, l = bs = {}
r = b, l = es = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p b
r = a, l = bs = {}
r = b, l = es = {f}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p b f
r = a, l = bs = {}
r = b, l = es = {f}
r = f, l = es = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p b f
r = a, l = bs = {}
r = b, l = es = {f}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p b f
r = a, l = bs = {}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p b f
r = a, l = bs = {c,d}
callstack
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree)r := root of Tif r is a leaf then list relsebegin l:= first child of r from left to right T(l) := subtree with l as its root inorder(T(l)) list r for each child c of r except for l left to right T(c) := subtree with c as its root preorder(T(c))end
output: j e n k o p b f a c l g m d h i
In which order does a postorder traversal visit the vertices in this ordered rooted tree?
In which order does a postorder traversal visit the vertices in this ordered rooted tree?
Infix, Prefix, and Postfix NotationInfix, Prefix, and Postfix Notation
represent complicated expressions using an ordered rooted tree (typically binary)
Algebraic expressions•preorder – Polish notation•inorder – infix notation•postorder – reverse Polish notation
Express in:a. Polishb. infixc. reverse Polish
Evaluating a prefix
expression
Evaluate postfix expression 7 2 3 * - 4 ^ 9 e / +
How do you do trees in Java?How do you do trees in Java?