{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# lecture19 - b Proceeds as far as possible to the left then...

This preview shows pages 1–11. Sign up to view the full content.

CSCI-255 Advanced Data Structures Lecture 19

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Inserting an Element into a BST (cont’d) Exercise: Write a recursive version of insert (DONE IN CLASS) Do 6.22(e) (DONE IN CLASS) Running Time?
Tree Traversal box3 Tree traversal is the process of visiting each node in the tree exactly one time square6 This definition does not specify the order in which the nodes are visited square6 For a tree with n nodes, how many different traversals there are? box3 n ! different traversals, but most of them are useless square6 Two main traversals: box3 Breadth-First box3 Depth-First

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Breadth-First Traversal box3 Visits each node starting from the lowest level and moving down level by level, visiting nodes on each level from left to right
DO 6.6 (c) (IN CLASS)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Depth-First Traversal

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: b Proceeds as far as possible to the left then backs up until the first crossroad, goes one step to the right, and again as far as possible to the left b This process is repeated until all nodes are visited b This definition does not specify exactly when nodes are visited: before proceeding down the tree or after backing up? s Preorder traversal s Inorder traversal s Postorder traversal Inorder Traversal b Left child, parent node, right child (DONE IN CLASS) Inorder Traversal (contd) Preorder Traversal b Parent node, left child, right child (DONE IN CLASS) Postorder Traversal b Left child, right child, parent node (DONE IN CLASS)...
View Full Document

• Spring '09
• Dr.IkerGondraLuja
• Articles with example pseudocode, Tree traversal, Nested set model, Graph algorithms, traversal Postorder traversal

{[ snackBarMessage ]}