Tree traversal: Difference between revisions

Content deleted Content added
No edit summary
T Long (talk | contribs)
Clarified intro by relating to computer science.
Line 1:
In [[computer science]], '''tree traversal''' is the process of visiting each node in a [[tree data structure]]. Tree traversal provides for sequential processing of each node in what is, by nature, a non-sequential data structure.
Often, one wishes to visit each of the nodes in a [[tree]] and examine the value there. There are several common orders of '''tree traversal''' in which the nodes can be visited.
Such traversals are characterised by the order in which the nodes are visited.
 
The following algorithms arare described for a [[binary tree]], but they may be generalized to other trees.
 
Say we have a tree node structure which contains a value <code>value</code> and references <code>left</code> and <code>right</code> to its two children. Then we can write the following function: