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 ...
随机推荐
- 一个漂亮的lazarus做的pagecontrol
厌倦了屏幕上的默认灰色?让我们来欣赏一下商业配色. 这个组件实现了高光,点睛色,描边边等效果, 再配几组色彩,应该非常不错. 基于 lazarus 1.08 大家可以上 www.fpccn.com 看 ...
- Laravel 5.5 + Vue 开发单页应用
上次我用 laravel5.3 + Vue 开发了一个简单的单页应用,这次我打算将其升级到 laravel5.5,在升级的过程中,做一下记录,其源码放在 github 上面,源码地址 开发环境 软 ...
- 好像leeceode题目我的博客太长了,需要重新建立一个. leecode刷题第二个
376. Wiggle Subsequence 自己没想出来,看了别人的分析. 主要是要分析出升序降序只跟临近的2个决定.虽然直觉上不是这样. 455. 分发饼干 ...
- Delegate,Action,Func,匿名方法,匿名委托,事件 (转载)
Delegate,Action,Func,匿名方法,匿名委托,事件 (转载) 一.委托Delegate 一般的方法(Method)中,我们的参数总是string,int,DateTime...这些基本 ...
- C#调用开源图像识别类库tessnet2
首先下载tessnet2_32.dll及相关语言包,将dll加入引用 private tessnet2.Tesseract ocr = new tessnet2.Tesseract();//声明一个O ...
- object SparkStreaming_StateFul {
窗口查询 ) )).reduceByKeyAndWindow(_+_,_-_,Seconds(10),Seconds(15)) 每隔15s进行查询,查询为前10s的结果.这里的值必须为采集时间 ...
- KM匹配板子
/* gyt Live up to every day */ #include<cstdio> #include<cmath> #include<iostream> ...
- GOAP
市面上Unity人工智能的书籍基本上都是介绍这几个方面: AI角色的自主移动 --- 操控行为, 单体,小队,群体的行为. 我之前的文章 Unity Movement AI (一) , Unity M ...
- windows10安装ubuntu on windows10
安装向导 https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
- 用rpm命令安装定时器crontab
crontab -l command not found 准备以下安装包: ls -l总用量 1004-rw-r--r-- 1 root root 76296 10月 9 16:01 croni ...