Java Applets Centre
Binary Tree Traversal


Description
This applet shows the sequence in which nodes in a binary tree are visited using traversal algorithms.


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


R. Mukundan
Department of Computer Science
University of Canterbury
Private Bag 4800, Christchurch
New Zealand.