[Arch] Java数据结构与算法 - 综述
博客首页 » Arch Java数据结构与算法 - 综述
发布于 18 Jul 2015 15:27标签 blog
![[structs-algrs-java]1-1-data-structs-overview-perf-1.png](http://7vzpyg.com1.z0.glb.clouddn.com/[structs-algrs-java]1-1-data-structs-overview-perf-1.png)
![[structs-algrs-java]1-1-data-structs-overview-perf-2.png](http://7vzpyg.com1.z0.glb.clouddn.com/[structs-algrs-java]1-1-data-structs-overview-perf-2.png)
Data Structure | 名称 | Advantages | Disadvantages |
Array | 数组 | Quick insertion, very fast access if index known. | Slow search, slow deletion, fixed size. |
Ordered array | 有序数组 | Quicker search than unsorted array. | Slow insertion and deletion, fixed size. |
Stack | 栈 | Provides last-in, first-out access. | Slow access to other items. |
Queue | 队列 | Provides first-in, first-out access. | Slow access to other items. |
Linked list | 链表 | Quick insertion, quick deletion. | Slow search. |
Binary tree | 二叉树 | Quick search, insertion, deletion (if tree remains balanced). | Deletion algorithm is complex. |
Red-black tree | 红黑树 | Quick search, insertion, deletion. Tree always balanced. | Complex. |
2-3-4 tree | 234树 | Quick search, insertion, deletion. Tree always balanced. Similar trees good for disk storage. | Complex. |
Hash table | 哈希表 | Very fast access if key known. Fast insertion. | Slow deletion, access slow if key not known, inefficient memory usage. |
Heap | 堆 | Fast insertion, deletion, access to largest item. | Slow access to other items. |
Graph | 图 | Models real-world situations. | Some algorithms are slow and complex. |
名称 | 特点 | 缺点 | 增 | 删 | 改 | 取 | 查 | 大小 |
数组 | 知道下标存取快 | 快 | 慢 | 快(若知下标) | 快(若知下标) | 慢 | 固定 | |
有序数组 | 比无序数组查找快 | 慢 | 慢 | 慢 | 快(若知下标) | 快(与数组比) | 固定 | |
栈 | 后进先出 | 快 | 快 | 慢 | 慢 | 慢 | ||
队列 | 先进先出 | 快 | 快 | 慢 | 慢 | 慢 | ||
链表 | 快 | 快 | 慢 | |||||
二叉树 | 删除复杂 | 快 | 快(若树平衡) | 快 | ||||
红黑树 | 树总平衡 | 复杂 | 快 | 快 | 快 | |||
234树 | 树总平衡 | 复杂 | 快 | 快 | 快 | |||
哈希表 | 浪费空间 | 快 | 慢(为何?) | 极快(需知key,若不知则慢) | 极快(需知key,若不知则慢) | |||
堆 | 对大数据项存取快 | 快 | 快 | 大数据项快,其他慢 | 大数据项快,其他慢 | 慢 | ||
图 | 建模 | 慢、复杂 |
本页面的文字允许在知识共享 署名-相同方式共享 3.0协议和GNU自由文档许可证下修改和再使用,仅有一个特殊要求,请用链接方式注明文章引用出处及作者。请协助维护作者合法权益。
系列文章
文章列表
- Arch Java数据结构与算法 - 综述
这篇文章对你有帮助吗,投个票吧?
留下你的评论