Determining the height of a non-binary tree
| Newsgroups | gmane.comp.ai.weka |
|---|---|
| Message-ID | <162451937053.117859.14459717480957703831@sys-mailman-prd.its.waikato.ac.nz> |
Dear Weka developers,
I am trying to build a Level-Order (a.k.a. Breadth First) Tree Traversal
technique for J48. In order to do this recursively, I have to determine
first the height of the tree. The method I have written is as follows:
int getHeight(Instances data){
int height=0;
if (data==null){
return 0;
} else {
for (int i=0; i<m_sons.length; i++) {
if (i == 0) {
height = getHeight(m_sons[i].m_train);
} else {
int currentHeight = getHeight(m_sons[i].m_train);
if (currentHeight > height) {
height = currentHeight + 1;
}
}
}
}
return height;
}
I get a StackOverflowException and at the code, the message
that the expression m_sons[i].m_train can not be evaluated.
Could you please help?
Thank you in advance,
Spyros Halkidis
_______________________________________________
Wekalist mailing list -- [email protected]
Send posts to [email protected]
To unsubscribe send an email to [email protected]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html