Java da TreeNode
//************TreeNode Sınıfı**************//
package treenode;
/**
*
* @author şerzan
*/
public class Tree {
private TreNode root;
public Tree(){root=null;}
public TreNode getRoot(){return root;}
}
//************TreNode sınıfı***************//
package treenode;
/**
*
* @author şerzan
*/
public class TreNode {
public int data;
public TreeNode leftChild;
public TreeNode rightChild;
public void displayNode(){
System.out.println(""+data+""); }
//*************Main sınıfı***************//
package treenode;
/**
*
* @author şerzan
*/
public class TreeNode {
public static void main(String[] args) {
}
private Object root;
public void preOrder(TreNode localRoot){
if(localRoot!=null){
localRoot.displayNode();
preOrder(localRoot.leftChild);
preOrder(localRoot.rightChild);
}
}
public void inOrder(TreNode localRoot){
if(localRoot!=null){
inOrder(localRoot.leftChild);
localRoot.displayNode();
inOrder(localRoot.rightChild);
}
}
public void postOrder(TreNode localRoot){
if(localRoot!=null){
postOrder(localRoot.leftChild);
postOrder(localRoot.rightChild);
localRoot.displayNode();
}
}
public void insert(int newdata){
TreNode newNode=new TreNode();
newNode.data=newdata;
if(root==null)
root=newNode;
else
{
TreNode current=(TreNode) root;
TreNode parent;
while(true){
parent=current;
if(newdata<current.data){
}
}
}
}
package treenode;
/**
*
* @author şerzan
*/
public class Tree {
private TreNode root;
public Tree(){root=null;}
public TreNode getRoot(){return root;}
}
//************TreNode sınıfı***************//
package treenode;
/**
*
* @author şerzan
*/
public class TreNode {
public int data;
public TreeNode leftChild;
public TreeNode rightChild;
public void displayNode(){
System.out.println(""+data+""); }
//*************Main sınıfı***************//
package treenode;
/**
*
* @author şerzan
*/
public class TreeNode {
public static void main(String[] args) {
}
private Object root;
public void preOrder(TreNode localRoot){
if(localRoot!=null){
localRoot.displayNode();
preOrder(localRoot.leftChild);
preOrder(localRoot.rightChild);
}
}
public void inOrder(TreNode localRoot){
if(localRoot!=null){
inOrder(localRoot.leftChild);
localRoot.displayNode();
inOrder(localRoot.rightChild);
}
}
public void postOrder(TreNode localRoot){
if(localRoot!=null){
postOrder(localRoot.leftChild);
postOrder(localRoot.rightChild);
localRoot.displayNode();
}
}
public void insert(int newdata){
TreNode newNode=new TreNode();
newNode.data=newdata;
if(root==null)
root=newNode;
else
{
TreNode current=(TreNode) root;
TreNode parent;
while(true){
parent=current;
if(newdata<current.data){
}
}
}
}
Yorumlar