1 / 8

Tree Traversal

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

dorisgray
Download Presentation

Tree Traversal

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tree Traversal

  2. Traversal Algorithms • preorder • inorder • postorder

  3. PreOrder Traversal

  4. Inorder Traversal

  5. Postorder Traversal

  6. In which order does a inorder traversal visit the vertices in this ordered rooted tree? procedureinorder(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

  7. In which order does a postorder traversal visit the vertices in this ordered rooted tree?

  8. 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

More Related