资源 · 指南或文章
Linked List
单向链表基础,包括与数组的取舍(线性访问时间、缓存局部性较差),并给出面试官常问操作的伪代码。
审核日期
打开原站: Linked List (在新标签页中打开原网站)练习这个主题以 技术 / 编程 模式打开练习面试官,然后在那里选择题目。
添加到路线图
把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。
来源内容语言:英语
Read this in other languages: 简体中文, Русский, 日本語, Português, 한국어, Español, Türkçe, Українська In computer science, a linked list is a linear collection of data elements, in which linear order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of data and a reference (in other words, a link) to the next node in the sequence. This structure allows for efficient insertion or removal of elements from any position in the sequence during iteration. More complex variants add additional links, allowing efficient insertion or removal from arbitrary element references. A drawback of linked lists is that access time is linear (and difficult to pipeline). Faster access, such as random access, is not feasible. Arrays have better cache locality as compared to linked lists.
PrepKit 概览
本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。
- 适合人群
- 来源未说明适用级别
- 形式
- 参考资料
涵盖内容
- 在尾部 Add 和在头部 Prepend 的伪代码,同时维护头指针和尾指针
- Contains 查找和按值 Remove,包括更新尾指针
- 正向遍历,以及一种每次从头查找前一个节点的平方级反向遍历
- 复杂度表:访问和查找 O(n),插入 O(1),删除 O(n),空间 O(n)
使用建议
这是 PrepKit 的学习建议,并非来源的说法。
实现每一段伪代码,然后写一个原地反转;页面没有包含这一操作。用长度为 0、1 和 5 的链表测试。
范围与局限
没有环检测或原地反转等经典面试题,展示的反向遍历是低效的嵌套循环版本。
获取方式与形式
GitHub 上的 README,trekhleb/javascript-algorithms(MIT);附有八种译本的链接。英文,免费阅读。
PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88
本概览的依据
- src/data-structures/linked-list/README.md
收录此条目的页面
订阅 PrepKit 通讯
可选。使用 PrepKit 并不需要订阅。