5. 理论讲解:数组、链表(Array、Linked List)
2018-11-21 本文已影响0人
博士伦2014
1. Array
![](https://img.haomeiwen.com/i12990158/44656eacc1c606c7.png)
![](https://img.haomeiwen.com/i12990158/2c3bf8f55a0ff8fc.png)
两种常见的数组操作:插入和删除
复杂度:
• Access: O(1)
• Insert: 平均 O(n)
• Delete: 平均 O(n)
特点:查询操作快,插入删除慢
2. Linked List
![](https://img.haomeiwen.com/i12990158/039888e0eb760a9f.png)
![](https://img.haomeiwen.com/i12990158/47bbaf4eb1fc1d22.png)
![](https://img.haomeiwen.com/i12990158/49128e8243c07fc4.png)
![](https://img.haomeiwen.com/i12990158/53f3d58ddbabe213.png)
2.1 Doubly Linked List
![](https://img.haomeiwen.com/i12990158/1f01d70376c3ea46.png)
特点:查询操作慢,插入删除很快
3. 时间复杂度
space O(n)
prepend O(1)
append O(1)
lookup O(n)
insert O(1)
delete O(1)