2015年3月1日星期日

Tree

    Tree is kind of basic data structure which is used for storing data.  Each tree only has one root and each non-root nodes has exactly one parent.  There are directed edges between some pairs of nodes.  In addition the number of edges in a sequence of nodes, called path, is the length of the this path.  In the following, there are some codes of tree class.
    First of all, it is the initialized function of tree class.
    Secondly, there are some method about tree class.  

    It is the method about counting leaves(nodes with no children).  In this method, we use a recursion to guarantee to get the basic nodes of the tree.


    It is the method about counting internal nodes (node with one or more children).  In this method, we use a recursion to find out all the nodes which does not have children from the root to the basis.  

没有评论:

发表评论