2017-08-07 19 views

回答

0

傳遞一個集合來存儲所有節點遍歷後訂單並在達到最低點時打印。

void printPathsRecur(Node node, int path[], int pathLen) 
    { 
     if (node == null) 
      return; 

     /* append this node to the path array */ 
     path[pathLen] = node.data; 
     pathLen++; 

     /* it's a leaf, so print the path that led to here */ 
     if (all node for the parrent is null) 
      printArray(path, pathLen); 
     else 
     { 
      for(int i=0;i<node.getChildLenth();i++){ 
      printPathsRecur(node.child[i], path, pathLen); 

     } 
    } 
相關問題