节点的深度是从根到该节点的边数,对不对?但是如何通过Java中的findDepth(Node node)之类的方法找到它?
答案 0 :(得分:0)
这是一个简单的递归练习。递归实施。
findDepth(Node node)
在findDepth
函数/方法的代码中执行以下操作:
1)如果节点具有父返回1 + findDepth(parent)
2)如果节点没有父节点(即是根节点),则返回0
答案 1 :(得分:0)
因此,基于this答案,已经在stackOverflow上,您可以执行以下操作:
File > Settings > Build, Execution, Deployment > Compiler