Linked List
链表是线性表的一种。线性表是最基本,最简单也是最常见的一种数据结构。
线性表中数据元素之间的关系是一对一的关系,除了第一个和最后一个数据元素外,其他数据元素都是首尾相接的。
线性表有两种存储方式,一种是顺序存储结果,另一种是链式存储结构。数组就是一种最为常见的典型的顺序存储结构。
相反,链式存储结构就是两个相邻的元素在内存中可能不是相邻的,每一个元素都有一个指针域,指针域一般是存储着
到下一个元素的指针。这种存储方式的优点是插入和删除的时间复杂度为O(1),不会浪费太多内存,添加元素的时候才会申请内存,删除元素的时候会释放内存。
缺点是访问的时间复杂度最坏为O(n).
顺序表的特性是随机读取,也就是访问一个元素的时间复杂度是O(1),链式表的特性是插入和删除的时间复杂度为O(1)。
链表就是链式存储的线性表。根据指针域的不同,链表分为单向链表,双向链表,循环链表等。
Array VS linked lists:
Arrays are great for storing things in a certain order, but they have drawbacks.
The capacity of the array must be fixed when it is created, and insertions and deletions at interior positions of an array can be time consuming if many elements
must be shifted.
An important property of a linked list is that it does not have a predetermined fixed size;it use space proportional to its current number of elements.When using a singly linked list, we can easily insert an element at the head of the list.
基本操作:
插入
删除
遍历
反向遍历
Linked List的更多相关文章
- [LeetCode] Linked List Random Node 链表随机节点
Given a singly linked list, return a random node's value from the linked list. Each node must have t ...
- [LeetCode] Plus One Linked List 链表加一运算
Given a non-negative number represented as a singly linked list of digits, plus one to the number. T ...
- [LeetCode] Odd Even Linked List 奇偶链表
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note her ...
- [LeetCode] Delete Node in a Linked List 删除链表的节点
Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...
- [LeetCode] Palindrome Linked List 回文链表
Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time ...
- [LeetCode] Reverse Linked List 倒置链表
Reverse a singly linked list. click to show more hints. Hint: A linked list can be reversed either i ...
- [LeetCode] Remove Linked List Elements 移除链表元素
Remove all elements from a linked list of integers that have value val. Example Given: 1 --> 2 -- ...
- [LeetCode] Intersection of Two Linked Lists 求两个链表的交点
Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...
- [LeetCode] Linked List Cycle II 单链表中的环之二
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...
- [LeetCode] Linked List Cycle 单链表中的环
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using ex ...
随机推荐
- BZOJ 3131 [SDOI2013]淘金 - 数位DP
传送门 Solution 这道数位$DP$看的我很懵逼啊... 首先我们肯定要先预处理出 $12$位乘起来的所有的可能情况, 记录入数组 $b$, 发现个数并不多, 仅$1e4$不到. 然后我们考虑算 ...
- SQL Server 2008数据库连接错误
以Windows身份连接SQL Server 2008数据库时,连接不上,出现如下报错画面: 解决办法:打开services窗口,找到名字类似于SQL Server (xxx)的服务,启动服务. 注: ...
- filedisk.sys
i386 amd http://blog.sina.com.cn/s/blog_4fcd1ea30100r19r.html
- PropertyPlaceholderConfigurer
PropertyPlaceholderConfigurer Spirng在生命周期里关于Bean的处理大概可以分为下面几步: 加载 Bean 定义(从xml或者从@Import等) 处理 BeanFa ...
- base64编码是什么
首先明确一点base64 是一种编码格式.就想utf-8一样,能在电脑上表示所有字符,或者换句话说通过编码能让电脑理解你想要标识的字符(因为电脑只知道0和1 ) 就像ascII 中 0100 0001
- 关于 construct object opp
constructor 定义和用法 constructor 属性返回对创建此对象的数组函数的引用. 语法 object.constructor 实例 例子 1 在本例中,我们将展示如何使用 const ...
- OpenCV-图像通道转换问题
OpenCV-MAT对象中使用plt.imshow(img[:,:,::-1])如何实现将第二轴反向? 系统平台:win10 x64 一.明确几个概念: 1.OpenCV内部每个通道并没有固定对应某种 ...
- kbmmw 的远程桌面功能2-android手机端
前面讲了PC 端的远程操作,今天讲一下如何用手机控制远程桌面(真的能操作的很爽吗?), 要使手机可以远程控制,首先在在kbmmwconfig.inc 文件里面加入FMX 支持 {$DEFINE KBM ...
- ACM-ICPC 2018 徐州赛区网络预赛 G Trace(逆向,两颗线段树写法)
https://nanti.jisuanke.com/t/31459 思路 凡是后面的轨迹对前面的轨迹有影响的,可以尝试从后往前扫 区间修改需要push_down,单点更新所以不需要push_up(用 ...
- mysql 入门 jdbc
在java程序中连接mysql,先要到mysql的网站上面去下载驱动,并且安装,默认安装在c盘(我的都是默认安装,目录为C:\Program Files\MySQL\MySQL Connector J ...