
Algorithm & STL
文章平均质量分 80
denisyq
这个作者很懒,什么都没留下…
展开
-
algorithm-查找、排序
最近看了算法的东西,将一些查找和排序的算法罗列一下,尽量做到不用查baidu,直接记在脑子里面。1.排序:1.1冒泡排序#include//bubble sortvoid bubSearch(int a[]){ int i,j; int tmp; for(i=0;i<10;i++){ for(j=0;j<10-i;j++){ if(a[j]>a[j+1]){原创 2013-01-06 17:39:08 · 650 阅读 · 0 评论 -
Algo classfication
这是一个大神对算法的分类,暂时是这样子的。再分享一个算法方面的网站,台湾人,做的也挺好的,演算法笔记############Optimization############Common:-Fake/dfs-DP/Greedy/BF-Binary Search/TS-Branch & Bound-RMQ/LCA-Line sweep-AlgoX原创 2014-12-25 16:23:28 · 719 阅读 · 0 评论 -
Dijkstra VS. Prim
Dijkstra & Prim 都是贪心算法的一种应用,在代码层面,你会发现他们很像,相异点仅一两行。Dijkstravoid dijkstra(void){ //c[][] = INF memset(visited,0,sizeof(visited)); memset(path,0,sizeof(path)); for(int i=1;i<=N;i++)原创 2014-03-12 15:52:20 · 681 阅读 · 0 评论 -
动态规划 - 矩阵连乘
有N个矩阵,分别是A1*A2, A2*A3, A3*A4, etc.....求连乘的最小结果。动态规划,其实也可以称作分解法,因为不知道在i --> j 中間哪裡斷開,所以要求所有值,然後更新到最小。下面的代碼中,fix()是從recursive角度來解決的,效率不高,但是思想是動態規劃的。fix2()是對fix的優化,降低時間複雜度,這個 一般對遞歸都是這麼的二維數組處理原创 2014-06-09 15:42:32 · 729 阅读 · 0 评论 -
背包问题-01/完全/多重
背包问题是典型的动态规划的问题对于0/1背包,东西有liangzho原创 2014-06-04 14:27:04 · 794 阅读 · 0 评论 -
STL_sort
STL 中的sort 有好几个,sort/partial_sort/partition/nth_element要include原创 2014-04-10 17:13:07 · 629 阅读 · 0 评论 -
STL_queue
queue and priority_queuepush/pop/top/emtpy/sizepriority_queue: default to sort the queue as 6.5.4.3, greater stands frontif we wanna ascending order, using__priority_queue, less > pri_原创 2014-03-25 15:02:47 · 537 阅读 · 0 评论 -
STL_list
#include #include #include using namespace std;int main (){ list ilist(10,12); int tmp[4] = {1,2,3,4}; list ilist2(tmp,tmp+4); list::iterator iter; ilist2.push_back(2); i原创 2014-03-24 17:14:38 · 480 阅读 · 0 评论 -
STL_map_multimap
map 是A->B, 只能有一个A,不允许后面再由A->C,如果需要A -> B and A ->C ,则需要multimap。map 可以用[] 来O(1)的寻址,Multimap不可以用[].map的主要的几个I/O, 有如 insert, find, count..... multimap 多了equal_range, lower_bound, upper_bound, co原创 2014-03-24 16:12:00 · 521 阅读 · 0 评论 -
STL_summary
http://www.cplusplus.com/reference/1. list front()/back()begin()/end()push_back()/pop_back()push_front()/pop_front()erase()/remove()insert()size()/empty()sort()/unique()原创 2014-03-26 15:57:45 · 699 阅读 · 0 评论 -
STL_Vector
#include #include #include #include #include #include #include #include using namespace std;bool cmp(const int& a, const int& b){ return a>b;}void print(vector& intv){ for(vect原创 2014-03-19 14:42:21 · 524 阅读 · 0 评论 -
Top 10 Algorithms for Coding Interview
The original address is here: http://www.programcreek.com/2012/11/top-10-algorithms-for-coding-interview/The following are top 10 algorithms related concepts in coding interview. I will try to ill转载 2013-11-28 13:58:55 · 811 阅读 · 0 评论 -
NOTES of "effective STL"
/************************** * NOTES of "Effective STL" * Written on May 13rd, 2016 * Author: Dennis LU * ************************/#1 容器1. 慎重选择容器类型 - 序列容器:vector / deque / list / str原创 2016-06-06 11:33:13 · 426 阅读 · 0 评论