Re: Determining the height of a non-binary tree

Eibe Frank <[email protected]>
Newsgroups gmane.comp.ai.weka
Message-ID <CADehzLV-_+kBdUJAN0upsgXqxFiY9F2+2PpH2mg9iGy_z+Ooug@mail.gmail.com>
In that case, put

public int getHeight(){
    int height=0;
    if (isLeaf()){
      return 0;
    }
    for (int i=0; i<m_sons.length; i++) {
      height = Math.max(height, m_sons[i].getHeight());
    }
    return height + 1;
  }
}

as a method into your version of ClassifierTree and then simply use

getHeight()

in the toString() method.

Cheers,

Eibe


On Fri, Jun 25, 2021 at 8:34 PM <[email protected]> wrote:

> Dear Professor Eibe Frank,
>
> first of all thank you for your reply! I would like to call getHeight
> from inside the toString() method of the ClassifierTree.java file
> in order to be able to select the appropriate dataset from the
> GUI. Could you please tell me which commands I should include
> in the toString() method in order to appropriately call the
> getHeight method (the commands in the main method do
> not work inside the toString() method).
>
> 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
>

_______________________________________________
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.