Log in

View Full Version : Menggabungkan Tree per level


Badguy13
20th November 2011, 12:47 AM
ni program sndiri gan.....

ada yg isa bntuin gabungin masing2 level ga gan??

THx before......



import java.util.*;

import java.io.*;

class Node

{

String ortu,isi;

int jumanak,jumchild;

Node child[] = new Node[3];



public Node(String parent, String a)

{

ortu=parent;

isi=a;

jumanak=jumchild;

}

}



public class tree

{

private Node root;



private boolean isEmpty()

{

return (root == null);

}



public void insert(String x,String y, int pos)

{

int coba;

coba = 0;

Node temp = new Node(x,y);

if (isEmpty())

{

root = temp;

System.out.println("root awal:"+root.isi);

root.jumchild=0;

}



else

{

root.jumchild++;

//System.out.println("jum child:"+root.jumchild+"y:"+y);

Node cursor = root,

parent = null;



coba = 1;

for ( int i=1;i