Zurück |
Binary Tree Traversal animation applet |
|
Binary Tree Traversal
Description
This applet shows the sequence in which nodes in a binary tree are visited using
traversal algorithms.
- Preorder: Displays the nodes visited using a preorder traversal algorithm, and displays the resulting expression.
- Inorder: Displays the nodes visited using a inorder traversal algorithm, and displays the resulting expression.
- Postorder: Displays the nodes visited using a postorder traversal algorithm, and displays the resulting expression.
Code
(Tree Node)
public class tNode{
int data;
tNode left;
tNode right;
}
|
Code
(Preorder traversal)
void preOrder(tNode n){
if(n==null) return;
visit(n);
preOrder(n.left);
preOrder(n.right);
}
|
Data Structures and Algorithms
Java Applets Centre
Quelle: http://www.cosc.canterbury.ac.nz/mukundan/dsal/BTree.html
R. Mukundan
Department of Computer Science
University of Canterbury
Private Bag 4800, Christchurch
New Zealand.