Jump to content

In-order traversal

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 202.177.170.112 (talk) at 16:24, 20 December 2003. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The in-order traversal of a Binary Search Tree always results in a sorted ( and that too increasing ) list of elements. In in-order traversal, the left subtree of every node is visited first. So if you take the example of the root, its left subtree will be visited first, then the root will be visited and then its right subtree will be visited.

Procedure IN_ORDER_TRAVERSAL(G) {

 IN_ORDER_TRAVERSAL(left[G])
 print key[G]
 IN_ORDER_TRAVERSAL(right[G])

}

The above code recursively in-order traverses the Graph G.