链表是什么
链表了解吗
-
Linked list is a sequence of links which contains items
-
Link - Each link of a linked list can store a data called an element
-
Next - Each link of a linked list contains a link to the next link called Next
-
LinkedList - A Linked List contains the connection link to the first link called First
-
Linked list can be visualized as a chain of nodes,where every node points to hte next node
![image](
- Simple linked list -item navigation is forward only
- doubly linked list - items can be navigated forward and backward
- circular linked list - last item contains link of the first element as next and the first element has a link to the last element as previous.
双向链表是什么
同上,节点有前后指针
跟数组的区别
- 数组在编译时已经分配好连续内存
- 链表在运行时添加数据时分配内存
- 数组在栈,链表在堆
数组为什么快
- 数组查找快,因为可以根据索引直接获得,复杂度O(1),链表复杂度O(N)
- 数组插入和删除慢,因为空间连续,插入删除后需要整理内存大小,链表插入删除快,只要改变指针指向即可
参考:1. https://www.tutorialspoint.com/data_structures_algorithms/linked_list_algorithms.htm
2.https://www.studytonight.com/data-structures/linked-list-vs-array
- 原文作者:知识铺
- 原文链接:https://geek.zshipu.com/post/iOS/what-is-link-list/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。
- 免责声明:本页面内容均来源于站内编辑发布,部分信息来源互联网,并不意味着本站赞同其观点或者证实其内容的真实性,如涉及版权等问题,请立即联系客服进行更改或删除,保证您的合法权益。转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。也可以邮件至 sblig@126.com