我尝试了许多编码来解决问题,但也无法找到答案。任何人都可以帮我解决我的问题,并告诉我错在哪里编码?编写一个递归方法来计算链节点链中的节点数
/** Task: Recusively counts the nodes in a chain.
* @param start the first node
* @returns the number of nodes in the linked chain */
public int countNodes(Node start)
{
if (start == null)
// base case
{
countNodes (Node start);
// recursive case
else
System.out.println (start.data);
return start.next;
}
} // end countNodes
请告诉我们您到目前为止尝试过的方法,然后我们可以帮助您改进它。如果这是作业,请相应标记:-) – 2010-09-09 08:32:08
这是一项家庭作业吗? – 2010-09-09 08:32:14
这是一项任务 – Tonberry 2010-09-09 08:35:42