View Single Post
  #1  
Old 20th November 2011
Badguy13 Badguy13 is offline
Ceriwiser
 
Join Date: Nov 2011
Posts: 399
Rep Power: 15
Badguy13 mempunyai hidup yang Normal
Default Menggabungkan Tree per level

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
Reply With Quote