0% found this document useful (0 votes)
10 views

Tree 2

This document discusses different tree traversal algorithms including preorder, inorder, and postorder traversal. It provides an example of an inorder traversal on an ordered rooted tree that outputs the vertices in the order j e n k o p b f a c l g m d h i. Postorder traversal is also discussed along with different notations for representing expressions using ordered rooted trees.

Uploaded by

zilangamba_s4535
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Tree 2

This document discusses different tree traversal algorithms including preorder, inorder, and postorder traversal. It provides an example of an inorder traversal on an ordered rooted tree that outputs the vertices in the order j e n k o p b f a c l g m d h i. Postorder traversal is also discussed along with different notations for representing expressions using ordered rooted trees.

Uploaded by

zilangamba_s4535
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Tree Traversal

Traversal Algorithms
preorder inorder postorder

PreOrder Traversal

Inorder Traversal

Postorder Traversal

In which order does a inorder traversal visit the vertices in this ordered rooted tree?
procedure inorder(T: ordered rooted tree) r := root of T if r is a leaf then list r else begin 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?

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

You might also like