1378535228 tree travers al 06
TRANSCRIPT
-
8/12/2019 1378535228 Tree Travers Al 06
1/71
Tree Traversal
-
8/12/2019 1378535228 Tree Travers Al 06
2/71
Traversal Algorithms
preorder
inorder
postorder
-
8/12/2019 1378535228 Tree Travers Al 06
3/71
PreOrder Traversal
-
8/12/2019 1378535228 Tree Travers Al 06
4/71
Inorder Traversal
-
8/12/2019 1378535228 Tree Travers Al 06
5/71
Postorder Traversal
-
8/12/2019 1378535228 Tree Travers Al 06
6/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output:
-
8/12/2019 1378535228 Tree Travers Al 06
7/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a
-
8/12/2019 1378535228 Tree Travers Al 06
8/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a
for each of {b, c, d}
-
8/12/2019 1378535228 Tree Travers Al 06
9/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a
for each of {b, c, d}
-
8/12/2019 1378535228 Tree Travers Al 06
10/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b
-
8/12/2019 1378535228 Tree Travers Al 06
11/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b
for each of {e, f}
-
8/12/2019 1378535228 Tree Travers Al 06
12/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b
for each of {e, f}
-
8/12/2019 1378535228 Tree Travers Al 06
13/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e
-
8/12/2019 1378535228 Tree Travers Al 06
14/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e
for each of {j, k}
-
8/12/2019 1378535228 Tree Travers Al 06
15/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e
for each of {j, k}
-
8/12/2019 1378535228 Tree Travers Al 06
16/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j
-
8/12/2019 1378535228 Tree Travers Al 06
17/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j
for each of {}
-
8/12/2019 1378535228 Tree Travers Al 06
18/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j
for each of {j, k}
-
8/12/2019 1378535228 Tree Travers Al 06
19/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k
-
8/12/2019 1378535228 Tree Travers Al 06
20/71
-
8/12/2019 1378535228 Tree Travers Al 06
21/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k
for each of {n, o, p}
-
8/12/2019 1378535228 Tree Travers Al 06
22/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n
-
8/12/2019 1378535228 Tree Travers Al 06
23/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n
for each of {}
-
8/12/2019 1378535228 Tree Travers Al 06
24/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n
for each of {n, o, p}
-
8/12/2019 1378535228 Tree Travers Al 06
25/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o
-
8/12/2019 1378535228 Tree Travers Al 06
26/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o
for each of {}
-
8/12/2019 1378535228 Tree Travers Al 06
27/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o
for each of {n, o,p}
-
8/12/2019 1378535228 Tree Travers Al 06
28/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o p
-
8/12/2019 1378535228 Tree Travers Al 06
29/71
-
8/12/2019 1378535228 Tree Travers Al 06
30/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o p
for each of {n, o,p}
-
8/12/2019 1378535228 Tree Travers Al 06
31/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o p
for each of {j, k}
-
8/12/2019 1378535228 Tree Travers Al 06
32/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o p
for each of {e, f}
-
8/12/2019 1378535228 Tree Travers Al 06
33/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o p f
-
8/12/2019 1378535228 Tree Travers Al 06
34/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o p f
for each of {}
-
8/12/2019 1378535228 Tree Travers Al 06
35/71
-
8/12/2019 1378535228 Tree Travers Al 06
36/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o p f
for each of {b, c, d}
-
8/12/2019 1378535228 Tree Travers Al 06
37/71
In which order does a preorder traversal visit
the vertices in this ordered rooted tree?
procedurepreorder(T: ordered rooted tree)
r:= root of T
list rforeach child cof rfrom left to right
begin
T(c) := subtree with cas its root
preorder(T(c))
end
output: a b e j k n o p f c d g l m h i
-
8/12/2019 1378535228 Tree Travers Al 06
38/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output:
-
8/12/2019 1378535228 Tree Travers Al 06
39/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output:
call
stack
r = a, l= ?
s = {}
-
8/12/2019 1378535228 Tree Travers Al 06
40/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output:
r = a, l= b
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
41/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output:
r = a, l= b
s = {}
r = b, l= ?
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
42/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output:
r = a, l= b
s = {}
r = b, l= e
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
43/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output:
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l= ?
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
44/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
45/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {}
r = j, l= ?
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
46/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e
r = a, l= b
s = {}
r = b, l= e
s = {}
r =e, l=j
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
47/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
48/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
r = k, l = ?
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
49/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
r = k, l = n
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
50/71
-
8/12/2019 1378535228 Tree Travers Al 06
51/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e n k
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
r = k, l = n
s = {}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
52/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e n k
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
r = k, l = n
s = {o,p}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
53/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e n k o
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
r = k, l = n
s = {o,p}
call
stack
r = o, l = ?
s = {}
-
8/12/2019 1378535228 Tree Travers Al 06
54/71
ll
-
8/12/2019 1378535228 Tree Travers Al 06
55/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
beginl:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e n k o p
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
r = k, l = n
s = {o,p}
call
stack
r = k, l = ?
s = {}
ll
-
8/12/2019 1378535228 Tree Travers Al 06
56/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
begin
l:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e n k o p
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
r = k, l = n
s = {o,p}
call
stack
hi h d d i d l i i
ll
-
8/12/2019 1378535228 Tree Travers Al 06
57/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
begin
l:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its root
preorder(T(c))
end
output: j e n k o p
r = a, l= b
s = {}
r = b, l= e
s = {}
r = e, l=j
s = {k}
call
stack
-
8/12/2019 1378535228 Tree Travers Al 06
58/71
I hi h d d i d l i i
ll
-
8/12/2019 1378535228 Tree Travers Al 06
59/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
begin
l:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its rootpreorder(T(c))
end
output: j e n k o p b
r = a, l= b
s = {}
r = b, l= e
s = {f}
call
stack
I hi h d d i d l i i
ll
-
8/12/2019 1378535228 Tree Travers Al 06
60/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
begin
l:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its rootpreorder(T(c))
end
output: j e n k o p b f
r = a, l= b
s = {}
r = b, l= e
s = {f}
r = f, l = e
s = {}
call
stack
I hi h d d i d l i i
ll
-
8/12/2019 1378535228 Tree Travers Al 06
61/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
begin
l:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its rootpreorder(T(c))
end
output: j e n k o p b f
r = a, l= b
s = {}
r = b, l= e
s = {f}
call
stack
I hi h d d i d t l i it
call
-
8/12/2019 1378535228 Tree Travers Al 06
62/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
begin
l:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its rootpreorder(T(c))
end
output: j e n k o p b f
r = a, l= b
s = {}
call
stack
I hi h d d i d t l i it
call
-
8/12/2019 1378535228 Tree Travers Al 06
63/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
begin
l:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its rootpreorder(T(c))
end
output: j e n k o p b f
r = a, l= b
s = {c,d}
call
stack
I hi h d d i d t l i it
-
8/12/2019 1378535228 Tree Travers Al 06
64/71
In which order does a inorder traversal visit
the vertices in this ordered rooted tree?
procedureinorder(T: ordered rooted tree)
r:= root of T
ifr is a leaf thenlist r
else
begin
l:= first child of rfrom left to right
T(l):= subtree with las its root
inorder(T(l))
list r
foreach child cof rexcept for lleft to right
T(c) := subtree with cas its rootpreorder(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
-
8/12/2019 1378535228 Tree Travers Al 06
65/71
In which order does a postorder traversal visit
the vertices in this ordered rooted tree?
-
8/12/2019 1378535228 Tree Travers Al 06
66/71
Infix, 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
-
8/12/2019 1378535228 Tree Travers Al 06
67/71
Express in:a. Polish
b. infix
c. reverse Polish
-
8/12/2019 1378535228 Tree Travers Al 06
68/71
Evaluating
a prefixexpression
-
8/12/2019 1378535228 Tree Travers Al 06
69/71
Evaluate postfix expression 7 2 3 * - 4 ^ 9 e / +
-
8/12/2019 1378535228 Tree Travers Al 06
70/71
-
8/12/2019 1378535228 Tree Travers Al 06
71/71
How do you do trees in Java?