Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task 1 #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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;
}
}


}