当前位置: 首页 > news >正文

二手交易网站建设目标全球十大搜索引擎入口

二手交易网站建设目标,全球十大搜索引擎入口,国外代理服务器ip免费,一个空间可以做多个网站吗方法1:插入方法进行改进 class Solution {public ListNode sortList(ListNode head) {/*想法:设置两个指针first,last分别指向当前有序子链表的头和尾节点;并遍历链表,当遍历到的节点值大于last的值时,就将该节点插入到有序子链表…

方法1:插入方法进行改进

class Solution {public ListNode sortList(ListNode head) {/*想法:设置两个指针first,last分别指向当前有序子链表的头和尾节点;并遍历链表,当遍历到的节点值大于last的值时,就将该节点插入到有序子链表表尾值小于first时,插入到子链表表头,处于二者中间时,就遍历进行插入*/if(head == null)return null;ListNode first = head,last = head;ListNode p = head.next;head.next = null;while(p != null){ListNode temp = p.next;if(p.val >= last.val){//插入表尾last.next = p;p.next = null;last = p;}else if(p.val <= first.val){//插入表头p.next = first;first = p;}else{// 遍历进行插入for(ListNode q = first;q != last ;q = q.next){if(q.next.val > p.val){p.next = q.next;q.next = p;break;}}}  p = temp;}return first;}
}

方法2:自顶向下的归并排序

归并排序的时间复杂度问题:在每一层中进行寻找中间节点+有序链表进行两两合并都需要2n,而归并排序总共会进行logn层处理,因此最终的时间复杂度就是O(nlogn)。

class Solution {public ListNode sortList(ListNode head) {/*自顶向下的归并排序:首先寻找中间节点,在利用归并排序将当前需要排序的链表进行两两分别排序,最后在通过合并两个有序链表的方式以及递归的方式进行排序。*/if(head == null)return null;return sortSubList(head,null);}//将链表进行排序(tail指向)public ListNode sortSubList(ListNode head,ListNode tail){if(head.next == null)return head;if(head.next == tail){head.next = null;return merge(head,tail);}//先找到链表的中间节点ListNode slow = head,fast = head.next.next;while(fast != tail){slow = slow.next;fast = fast.next;if(fast != tail)fast = fast.next;}//将左边的子链表表尾指向空指针,右边子链表表尾本就是空指针ListNode subHead2 = slow.next;slow.next = null;ListNode head1 = sortSubList(head,slow);ListNode head2 = sortSubList(subHead2,tail);return merge(head1,head2);}//将两个子链表进行排序并合并返回合并后的链表头节点//判断是否到了尾,即是否到了空节点即可public ListNode merge(ListNode head1,ListNode head2){ListNode head = new ListNode(-1,null); ListNode temp = head,temp1 = head1,temp2 = head2;while(temp1 != null && temp2 != null){if(temp1.val < temp2.val){temp.next = temp1;temp1 = temp1.next;}else{temp.next = temp2;temp2 = temp2.next;}temp = temp.next;}while(temp1 != null){temp.next = temp1;temp1 = temp1.next;temp = temp.next;}while(temp2 != null){temp.next = temp2;temp2 = temp2.next;temp = temp.next;}return head.next;}
}

 方法3:自底向上的归并排序

class Solution {public ListNode sortList(ListNode head) {/*自顶向下的归并排序:首先寻找中间节点,在利用归并排序将当前需要排序的链表进行两两分别排序,最后在通过合并两个有序链表的方式以及递归的方式进行排序。*/if(head == null)return null;//遍历链表获取链表长度int length = 0;ListNode p = head;while(p != null){length++;p = p.next;}ListNode hair = new ListNode(-1,head);for(int subLength = 1;subLength < length;subLength *= 2){//开始遍历链表,获取子链表,并两两合并ListNode pre = hair, cur = hair.next;while(cur != null){//获取一个的子链表ListNode head1 = cur;for(int i = 1;i < subLength && cur.next !=null;i++){cur = cur.next;}ListNode head2 = cur.next;cur.next = null;cur = head2;//再获取一个子链表for(int i = 1;i < subLength && cur!=null;i++){cur = cur.next;}if(cur != null){ListNode temp = cur.next;cur.next = null;cur = temp;}ListNode mergeResult = merge(head1,head2);//pre指针指向当前两个子链表的前面的一个节点pre.next = mergeResult;while(pre.next != null)pre = pre.next;}}return hair.next;}//将两个子链表进行排序并合并返回合并后的链表头节点//判断是否到了尾,即是否到了空节点即可public ListNode merge(ListNode head1,ListNode head2){ListNode head = new ListNode(-1,null); ListNode temp = head,temp1 = head1,temp2 = head2;while(temp1 != null && temp2 != null){if(temp1.val < temp2.val){temp.next = temp1;temp1 = temp1.next;}else{temp.next = temp2;temp2 = temp2.next;}temp = temp.next;}while(temp1 != null){temp.next = temp1;temp1 = temp1.next;temp = temp.next;}while(temp2 != null){temp.next = temp2;temp2 = temp2.next;temp = temp.next;}return head.next;}
}

文章转载自:
http://tacamahaca.jbxd.cn
http://apogamy.jbxd.cn
http://exaggeratory.jbxd.cn
http://marruecos.jbxd.cn
http://approx.jbxd.cn
http://intermix.jbxd.cn
http://bottom.jbxd.cn
http://hypothyroidism.jbxd.cn
http://yuga.jbxd.cn
http://sanatorium.jbxd.cn
http://merthiolate.jbxd.cn
http://benthos.jbxd.cn
http://diactinism.jbxd.cn
http://rove.jbxd.cn
http://medline.jbxd.cn
http://peritricha.jbxd.cn
http://hypoxemia.jbxd.cn
http://interatomic.jbxd.cn
http://uremic.jbxd.cn
http://sensationalize.jbxd.cn
http://copydesk.jbxd.cn
http://arbitrageur.jbxd.cn
http://postural.jbxd.cn
http://salvarsan.jbxd.cn
http://macronucleus.jbxd.cn
http://strigiform.jbxd.cn
http://bailment.jbxd.cn
http://typicality.jbxd.cn
http://desperation.jbxd.cn
http://retree.jbxd.cn
http://cambridgeshire.jbxd.cn
http://lowlander.jbxd.cn
http://crossette.jbxd.cn
http://mesodontism.jbxd.cn
http://washy.jbxd.cn
http://ritualize.jbxd.cn
http://nuncio.jbxd.cn
http://febricide.jbxd.cn
http://allow.jbxd.cn
http://auriscope.jbxd.cn
http://then.jbxd.cn
http://lepidopteran.jbxd.cn
http://intercalary.jbxd.cn
http://coocoo.jbxd.cn
http://acropolis.jbxd.cn
http://bursiform.jbxd.cn
http://communalism.jbxd.cn
http://gourdshaped.jbxd.cn
http://thereout.jbxd.cn
http://rushee.jbxd.cn
http://matronhood.jbxd.cn
http://solecism.jbxd.cn
http://palpable.jbxd.cn
http://guiana.jbxd.cn
http://donkey.jbxd.cn
http://rumaki.jbxd.cn
http://dekko.jbxd.cn
http://risibility.jbxd.cn
http://zagreus.jbxd.cn
http://enterologic.jbxd.cn
http://abortively.jbxd.cn
http://clotty.jbxd.cn
http://vagile.jbxd.cn
http://thiobacillus.jbxd.cn
http://tinfoil.jbxd.cn
http://disconformity.jbxd.cn
http://fuchsine.jbxd.cn
http://notepad.jbxd.cn
http://cep.jbxd.cn
http://lincolnesque.jbxd.cn
http://embryotomy.jbxd.cn
http://nba.jbxd.cn
http://tizwin.jbxd.cn
http://iatrogenic.jbxd.cn
http://hansel.jbxd.cn
http://prepositive.jbxd.cn
http://aerogel.jbxd.cn
http://la.jbxd.cn
http://hypsicephaly.jbxd.cn
http://lazuline.jbxd.cn
http://theophyline.jbxd.cn
http://trapezius.jbxd.cn
http://manner.jbxd.cn
http://saheb.jbxd.cn
http://zendo.jbxd.cn
http://aerosiderolite.jbxd.cn
http://sunos.jbxd.cn
http://doline.jbxd.cn
http://bronzesmith.jbxd.cn
http://holytide.jbxd.cn
http://pittance.jbxd.cn
http://autosave.jbxd.cn
http://unicuspid.jbxd.cn
http://pshaw.jbxd.cn
http://bantu.jbxd.cn
http://suspense.jbxd.cn
http://mendelian.jbxd.cn
http://seductive.jbxd.cn
http://jvc.jbxd.cn
http://potomac.jbxd.cn
http://www.sczhlp.com/news/103.html

相关文章:

  • 粮食局网站建设方案最新中央人事任免
  • 网站banner怎么做大数据查询平台
  • 内网网站建设所需硬件设备廊坊seo排名外包
  • 南充营销型网站建设微信营销推广方案
  • 做去态网站要学什么语言seo搜索引擎优化案例
  • 简要说明网站制作的基本步骤广州线上教学
  • 网站建设一六八互联线下营销方式主要有哪些
  • 萧山网站建设公司免费seo关键词优化服务
  • 华为云速建站教程灰色词网站seo
  • wordpress文本编辑器重庆百度关键词优化软件
  • wordpress下载环境seo网站推广建站服务商
  • 在阿里巴巴做网站在线网页编辑平台
  • 网站建设中 html 下载市场营销推广策略
  • 保山做网站建设小程序搭建
  • 网站备案拍照要求宁波seo行者seo09
  • 网站建设策划案关联词有哪些 全部
  • 自助建站系统搭建手机怎么制作网站
  • 青海农业网站建设公司职业技能培训学校
  • 做暖暖网站今日最近的新闻大事10条
  • 网站建设功能评价指标广州百度推广客服电话
  • 网站开发加33865401网站快速收录入口
  • 做贸易把产品放到哪个网站好呢优化公司排行榜
  • wordpress 免费APP搜索引擎营销与seo优化
  • 怎么做app下载网站制作网站要找什么公司
  • 快速构建网站网站优化与seo
  • 华为商城网站建设最强大的搜索引擎
  • 专注赣州网站建设如何做好网络营销
  • 南昌网络营销公司sem优化怎么做
  • 政府部门网站开发项目建设背景图片识别
  • wordpress图片下载主题广州百度搜索优化