-
Tree Traversal Questions
According to the tree at http://www.geocities.com/beamer7296/images/tree.JPG, can someone please check my traversals below to see if thry're all correct!?! I'd really appreciate it!
Level-order traversal - A, B, D, E, F, H, J, K, M, Q, R, S, T, U, C, W, X, Y
Preorder traversal - A, B, E, K, X, T, Y, U, M, F, D, H, Q, C, W, J, R, S
Postorder traversal - K, X, T, Y, U, M, E, F, B, C, W, Q, H, R, S, J, D, A
Inorder traversal - K, E, M, T, X, U, Y, B, F, A, D, H, Q, C, W, J, R, S
-
I think that the orders would go as follows:
preorder - you "print" when you first hit the node
A, B, E, K, M, T, X, U, Y, F, D, H, Q, C, W, J, R, S
inorder - you "print" after the traversal returns from a visit down the sub-tree rooted by your left child, before you traverse down the subtree rooted by your right child
K, E, T, X, M, Y, U, F, C, Q, W, H, D, R, J, S
postorder - you "print" after return from both children
K, X, T, Y, U, M, E, F, B, C, W, Q, H, R, S, J, D, A
Similar Threads
-
Replies: 0
Last Post: 02-21-2006, 08:47 PM
-
Replies: 0
Last Post: 11-07-2005, 02:48 AM
-
By anbaz in forum ASP.NET
Replies: 2
Last Post: 06-15-2005, 09:09 PM
-
Replies: 3
Last Post: 03-04-2002, 07:27 AM
-
By Martin Lam in forum Database
Replies: 2
Last Post: 01-15-2001, 11:30 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks