Thread: Understanding an "Inorder Traversal"

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    68

    Understanding an "Inorder Traversal"

    I'm a little confused on what an "Inorder Traversal" is. All the sites I go to say:

    1. Traverse the left subtree; and then
    2. visit the root; and then
    3. traverse the right subtree.

    Looking at this tree: http://www.math.bas.bg/~nkirov/2010/.../ch06/pic3.jpg

    Would an "Inorder Traversal" go:

    A -> B -> D -> B -> E -> H -> E -> I -> E -> B -> A -> C -> F -> C -> G -> C -> A

    ?

    Only printing each "node" when it visits it the last time?

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,059
    Bingo! inorder tree traversal happens recursively at each node.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Location
    INDIA
    Posts
    64
    In inorder traversal If that node is the parent of some other node(s) then traverse to the left child . If there is a sub tree traverse recursively till the left node's availability.Then process with that left child.Then process with the current parent .Then goto the right child of the parent and process it.


    Left child->Parent -> Right
    Last edited by karthigayan; 02-25-2010 at 03:11 AM.

  4. #4
    Registered User
    Join Date
    Apr 2009
    Posts
    66

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Understanding the Linker Map File
    By Hops in forum C Programming
    Replies: 0
    Last Post: 01-14-2010, 05:40 PM
  2. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  3. Understanding Headers
    By AeonMoth in forum C++ Programming
    Replies: 2
    Last Post: 06-27-2007, 05:53 AM
  4. trouble understanding the source file structure
    By Mario F. in forum C++ Programming
    Replies: 5
    Last Post: 05-26-2006, 06:46 PM
  5. understanding recursive functions
    By houler in forum C Programming
    Replies: 7
    Last Post: 12-09-2004, 12:56 PM