STL and Big O Cheat Sheet
2015-10-27 18:53
316 查看
Name: list
Purpose:Linked list
Usage: list<int> x; x.push_back(5);
Insertingan item (top, middle*, or bottom):
O(1)
Deletingan item (top, middle*, or bottom): O(1)
Accessingan item (top or bottom):
O(1)
Accessingan item (middle): O(n)
Findingan item:
O(n)
*Butto get to the middle, you may have to first iterate through X items, at cost
O(x)
Name: vector
Purpose: Aresizable array
Usage: vector<int>v; v.push_back(42);
Insertingan item (top, or middle):
O(n)
Insertingan item (bottom): O(1)
Deletingan item (top, or middle):
O(n)
Deletingan item (bottom): O(1)
Accessingan item (top, middle, or bottom):
O(1)
Findingan item:
O(n)
Name: queue
and stack
Purpose:Classic stack/queue
Usage: queue<long> q; q.push(5);
Insertinga new item: O(1)
Poppingan item: O(1)
Examiningthe top: O(1)
Name: map
Purpose: Mapsone item to another
Usage: map<int,string>m; m[10] = “Bill”;
Insertinga new item: O(log2n)
Findingan item: O(log2n)
Deletingan item: O(log2n)
Name: set
Purpose:Maintains a set of unique items
Usage: set<string> s; s.insert(“Ack!”);
Insertinga new item: O(log2n)
Findingan item: O(log2n)
Deletingan item: O(log2n)
Purpose:Linked list
Usage: list<int> x; x.push_back(5);
Insertingan item (top, middle*, or bottom):
O(1)
Deletingan item (top, middle*, or bottom): O(1)
Accessingan item (top or bottom):
O(1)
Accessingan item (middle): O(n)
Findingan item:
O(n)
*Butto get to the middle, you may have to first iterate through X items, at cost
O(x)
Name: vector
Purpose: Aresizable array
Usage: vector<int>v; v.push_back(42);
Insertingan item (top, or middle):
O(n)
Insertingan item (bottom): O(1)
Deletingan item (top, or middle):
O(n)
Deletingan item (bottom): O(1)
Accessingan item (top, middle, or bottom):
O(1)
Findingan item:
O(n)
Name: queue
and stack
Purpose:Classic stack/queue
Usage: queue<long> q; q.push(5);
Insertinga new item: O(1)
Poppingan item: O(1)
Examiningthe top: O(1)
Name: map
Purpose: Mapsone item to another
Usage: map<int,string>m; m[10] = “Bill”;
Insertinga new item: O(log2n)
Findingan item: O(log2n)
Deletingan item: O(log2n)
Name: set
Purpose:Maintains a set of unique items
Usage: set<string> s; s.insert(“Ack!”);
Insertinga new item: O(log2n)
Findingan item: O(log2n)
Deletingan item: O(log2n)
相关文章推荐
- 移动web开发经验总结(1) (转)
- sqlite查询,分页查询
- android里面隐藏控件的方法
- ACM vim配置
- URAL 1309 Dispute (数学+推导)
- 继续linux学习
- java中的抽象类与接口
- Git常用命令(转)
- Android引入高速缓存的异步加载全分辨率
- Android 基础控件 TextView
- 用Binary Viewer查看H264文件中的每一帧
- beggo 模板函数
- nginx rewite指令模块
- 行为型模式之一——职责链模式
- 导向滤波磨皮 算法的实现
- IO字符流之读写缓冲区(BufferedWriter、BufferedReader)
- c++单链表基本操作
- python 学习笔记(01)
- 第七周数据结构之自建算法库——顺序环形队列【项目2 - 建立链队算法库】
- 【工具】字符串 加密 解密 不可逆加密 拆分 合并