Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/Tree.java
Original file line number Diff line number Diff line change
@@ -1,2 +1,35 @@
import java.util.ArrayList;

public class Tree {
private Object root;
private ArrayList<Tree> subtree;

public Tree( Object root, ArrayList<Tree> subtree){
this.root = root;
if (subtree == null){
this.subtree = new Arraylist<Tree>();
}
else {
this.subtree = subtree;
}
}

public boolean isEmpty(){
return this.root == null;
}

public int len(){
if (this.isEmpty()){
return 0;
}
else{
int size = 1;
for(Tree i : this.subtree){
size += i.len();
}
return size;
}
}


}