简体   繁体   English

Java实现中已排序和未排序链接列表的合并

[英]Merge of sorted and unsorted linked lists in java implementation

I was reading about sorted linked lists and unsorted sorted lists ... I found this table http://bigocheatsheet.com/ 我正在阅读有关排序的链表和未排序的链表的信息……我发现此表http://bigocheatsheet.com/

I do not understand what they mean by saying in the third table that a sorted linked list has Merge of O(m+n) while an unsorted sorted list has Merge of O(1) ! 我在第三张表中说排序的链表的合并数为O(m+n)而未排序的链表的合并数为O(1)这并不意味着他们的意思!

What does that mean? 这意味着什么?

thanks 谢谢

It's saying that the optimal time to merge a sorted list is O(m + n), because you have to traverse both lists, compare the top/bottom and decide which is higher / lower. 这就是说,合并排序列表的最佳时间是O(m + n),因为您必须遍历两个列表,比较顶部/底部并确定哪个位置更高/更低。 Unsorted list could in theory be merged in O(1) if this is a linked list... you just point the tail of the first linked list to the second linked list 理论上,如果这是一个链表,则未排序的链表可以合并到O(1)中……您只需将第一个链表的尾部指向第二个链表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM