这样的递归有什么问题吗? 补充一下,上面实现的是归并排序split()用于拆分mergeNode()用于合并两个有序的子表。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private LinkNode mergeSortHelp(LinkNode head) { LinkNode otherFirst; if(head!=null) { if(head.next!=null) { otherFirst=split(head); head=mergeSortHelp(head); otherFirst=mergeSortHelp(otherFirst); head=mergeNode(head,otherFirst); } } return head; }上面的head没有经过任何修改就进入递归,肯定要出这样的错误的 因为split()返回的中间的LinkNode,split()中head已经改变了 那在split方法中if(head.next.next==null) return head.next;这个条件如果为真的话,head还是没有变就返回了 tomcat连接sql2005~新手求教 一算法,敬请指导 JDBC实现分页 一个简单的编程题,大家帮我想想。 路径 如何让菜单栏里面的字变大点变漂亮点亚? 事件监听器应放在程序中的什么地方(就是像button.addMouseListener(this);这样的) redhat7.3下,java程序打印中文直接用java命令执行正常,用crontab执行为乱码 我写了一个java文件,遇到这样的编译错误: 关于JDK下载安装问题 日期转换问题! 大家有没有java解压和压缩的代码呀!就象winzip这样的功能.谢谢了。
{
LinkNode otherFirst;
if(head!=null)
{
if(head.next!=null)
{
otherFirst=split(head);
head=mergeSortHelp(head);
otherFirst=mergeSortHelp(otherFirst);
head=mergeNode(head,otherFirst);
}
}
return head;
}
上面的head没有经过任何修改就进入递归,肯定要出这样的错误的
split()中head已经改变了
if(head.next.next==null) return head.next;
这个条件如果为真的话,head还是没有变就返回了