From 9acc631e2b7a4d5aae2fee415f666add687c4f23 Mon Sep 17 00:00:00 2001 From: Mayank Date: Tue, 3 Nov 2015 15:46:08 +0530 Subject: [PATCH 01/32] Initial commit --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..efca67af5 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Algorithms +A Repository to store implementation of some of the famous Data Structures and Algorithms (mainly in C/C++/Java/Python) for everyone to learn and contribute. From 3a1818dbc9a1497e9acd3709317a061930f02e1b Mon Sep 17 00:00:00 2001 From: Mayank Date: Tue, 3 Nov 2015 15:53:46 +0530 Subject: [PATCH 02/32] Edit Distance completed --- editDistance/CODECHEF_seatsr.cpp | 78 +++++++++++++++++++++++++++++++ editDistance/SPOJ_edist.cpp | 42 +++++++++++++++++ editDistance/a.out | Bin 0 -> 13600 bytes 3 files changed, 120 insertions(+) create mode 100644 editDistance/CODECHEF_seatsr.cpp create mode 100644 editDistance/SPOJ_edist.cpp create mode 100755 editDistance/a.out diff --git a/editDistance/CODECHEF_seatsr.cpp b/editDistance/CODECHEF_seatsr.cpp new file mode 100644 index 000000000..549f90ee4 --- /dev/null +++ b/editDistance/CODECHEF_seatsr.cpp @@ -0,0 +1,78 @@ +// Two 1-d array implementation +#include +using namespace std; +const int inf=0x3fffffff; +#define Min(a,b) (a>test ; + while(test--) + { + cin>>a; + cin>>b; + cin>>z; + cin>>x; + cin>>c; + lena = strlen(a) ; + lenb = strlen(b) ; + if((lena-lenb)*z > c || (lenb-lena)*z > c ) + { + cout<<"-1\n"; + continue ; + } + if( (z == 0) ) + { + cout<<"0\n" ; + continue ; + } + if( (x == 0) ) + { + cout< c) + previous_dp[i] = inf ; + else + previous_dp[i] = i*z ; + } + fr(i,1,lena+1) + { + alpha = Max((i-c),0) ; + if( alpha > 0) + { + current_dp[alpha-1] = inf ; + } + alpha -= 1 ; + temp = Min((i+c+1),(lenb+1)); + fr(j,alpha+1,temp) + { + if(j == 0) + { + current_dp[j] = i*z ; + } + else + { + current_dp[j] = Min(Min(previous_dp[j] + z , current_dp[j-1] + z ) , previous_dp[j-1]+(a[i-1] == b[j-1] ? 0 : x)); + } + } + fr(j,alpha,temp) + { + previous_dp[j] = current_dp[j] ; + } + } + if(current_dp[lenb] > c) + cout<<"-1\n"; + else + cout< +using namespace std; +#define Min(a,b) (a>test ; + while(test--) + { + cin>>a; + cin>>b; + lena = strlen(a) ; + lenb = strlen(b) ; + dp[lena+1][lenb+1]; + fr(i,0,lena+1) + { + fr(j,0,lenb+1) + { + if( i == 0 ) + { + dp[i][j] = j ; + } + else if( j == 0 ) + { + dp[i][j] = i ; + } + else + { + dp[i][j]=Min(Min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]+(a[i-1]==b[j-1]?0:100)); + } + cout<Pnm3MlAO3{oF|H;EH)I$ zk&m7nAgK*mX<1pRvCV-y><@1!umMAspc@J=Lv7j4;tWVJr&x=kO$#Ai1}Sm^H%(JD zO|1RSz4wrhPh=N#!2X%8z<2KX-E+=8_q_Y@?t52X?&{fB<#Gv5RpRr4xC^yG38^di z2FYryO{@|@u}N$cD}dDC7nCJLRgUR`HqEqF%eg_T@oTG6KwDK%W|)3b!GbA!NR;X; zrl8I$def&^rb757Kziis!lxt)Iw&(tzpDKZsd^=#^#~@t`b`S1-!v#QOlQb25>sv; zwT*rQ+U`JA5FGJABBE1XirrBrpEWV)IvCdg*gNss8$fr>V??AK6gt@}ZknOAL^p@MND|S+%|E`#tN= zujwGHTp~aGWePS|z|R1`vy6Ncj+Db6u7I~xus>J9es2Xkhbq{4u7aJt73}P+fS;;h z=bOOSi4EeUe-JtJf9O++<4195)bj&jl(wLp=UaSK3KS0AtzSdK?bIGc%uN4p2ifkv~df4AA&--4DvH<9iB?W!rQ8X17%F0=QK zB2uq4lFC`qy;LIGHAXRuaJUeu$m3>YTxt1-MF87=tv@h|;whKmJn^F7Uf>FKHY#;#U`sucZ-u zTw}R=;;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8d{eqosg6dnU}zFB}XV=|2hD#UY5EmWYvY+>Ilq|JQ z=iVIFf7_9|-|gU`2rJEePK|L=O9&sifLtqb?P^hjQ@m951id=B+kGAiu- zxo{@YDJP%fvwAaNlA`|Zm_*}DJ z<4pK@hWRFB?E1Wau(ZK@Sx{4_ekbtvu{Y-W&sPPdk~^d?7xP^6UdOOtk3(UwAMGYpfi5l{?l5&UCZ(N zkBeHL-pugGVxq+h`>$#J0>!yg&|!s!N_h~wKJU|JwEnb~W5Vy3nEr)B zpPv&iXh*-rj%fp|$M*ixq0jri0evWx-}A7%)Bg)vpX1NZZG&3>E>_gkssDElef~cH z{{Mi^|3UxT4t?HlUexusIyx-hKQ=p!j0Zm&1C;prp8sFK884^)tI(mUSfBR|wVTLV zvA-y8DgQ$hkc+I(`$XTz)c*-|=@zp-?}zKP{)}!vcLVmH+x1_L`gz~Huo(qNEU&mC z&-gqF?EV+_*M6muW<^a|kLi2B?fSf5O8b=p`>EBJ`11h@$QHMspIcA*mBv_tN2=mA ztQcHr!%p=#77&$T{XPdyvXq#vL!RrF1^V(mzsm6Z!DXyx=XvZfMs#M2;?C=N;8S2} Yt>L(Ft7v?dtAA{V(*KNOz&Y#xZwceRJpcdz literal 0 HcmV?d00001 From 06e229ac6edd3f4e26eed41410619fe292ec7d5e Mon Sep 17 00:00:00 2001 From: Mayank Date: Wed, 4 Nov 2015 01:07:31 +0530 Subject: [PATCH 03/32] Binary Indexed Tree added- Part 1 --- binaryIndexedTree/SPOJ_invcnt.cpp | 78 +++++++++++++++++++ binaryIndexedTree/binary_indexed_tree.cpp | 76 ++++++++++++++++++ .../SPOJ_horrible.cpp | 76 ++++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100644 binaryIndexedTree/SPOJ_invcnt.cpp create mode 100644 binaryIndexedTree/binary_indexed_tree.cpp create mode 100644 binaryIndexedTree/range_query_range_update/SPOJ_horrible.cpp diff --git a/binaryIndexedTree/SPOJ_invcnt.cpp b/binaryIndexedTree/SPOJ_invcnt.cpp new file mode 100644 index 000000000..d15385bec --- /dev/null +++ b/binaryIndexedTree/SPOJ_invcnt.cpp @@ -0,0 +1,78 @@ +// Solution to ...https://www.hackerrank.com/challenges/insertion-sort +#include +#include +#include +#include +#include +using namespace std; +#define lli long long int +#define Min(a,b) (a s ; i--) + +//lli sum( lli index) : returns of arr[index]+arr[index-1]..arr[0] + +//void update( lli n , lli index , lli value ) : adds v to arr[index] + + +lli T[100002]={0} ; +lli sum(lli index){ + lli sum = 0; + index+=1; + while(index > 0){ + sum += T[index] ; + index = index - (index&(-1*index)); + } + return sum ; +} +void update(lli n , lli index , lli value ){ + index++; + while(index <= n){ + T[index] += value ; + index = index + (index&(-1*index)); + } +} +void binary_indexed_tree(lli *a, lli n){ + lli i ; + for(i = 1 ; i <= n+1 ; i++) + { + T[i] = 0 ; + } + //To be Uncommented as per the need + /*for(i = 0 ; i < n ; i++) + { + update(n,i,a[i]) ; + }*/ +} +int main() { + lli test,n,i,j,inversions,position,option,ans,p,q,v; + lli arr[100002]; + lli brr[100002]; + cin>>test; + while(test--) + { + inversions = 0; + cin>>n; + fr(i,0,n) + { + cin>>arr[i]; + brr[i] = arr[i] ; + } + sort(brr,brr+n); + fr(i,0,n) + { + position = ( lli )(lower_bound(brr,brr+n,arr[i])-brr); + arr[i] = position+1 ; + } + binary_indexed_tree(arr,n); + ufr(i,n-1,-1) + { + inversions += sum(arr[i]-1); + update(n,arr[i],1); + } + cout< +#include +#include +#include +#include +using namespace std; +#define lli long long int +#define Min(a,b) (a 0){ + sum += T[index] ; + index = index - (index&(-1*index)); + } + return sum ; +} +void update(lli n , lli index , lli value ){ + index++; + while(index <= n){ + T[index] += value ; + index = index + (index&(-1*index)); + } +} +lli * binary_indexed_tree(lli *a, lli n){ + lli i ; + for(i = 1 ; i <= n+1 ; i++) + { + T[i] = 0 ; + } + for(i = 0 ; i < n ; i++) + { + update(n,i,a[i]) ; + } + return T ; +} +int main() { + lli test,n,i,j,query,option,ans,p,q,v; + lli arr[200002]; + cin>>test; + while(test--) + { + cin>>n; + cin>>query; + fr(i,0,n) + { + arr[i] = 0; + } + binary_indexed_tree(arr,n); + while(query--) + { + cin>>option>>p>>q ; + p--; + q--; + if(option == 0) + { + cin>>v; + update(n,p,v); + if(q != n-1) + update(n,q+1,-1*v); + } + else + { + if(p == 0) + ans = sum(q); + else + ans = sum(q)-sum(p-1) ; + cout< +#include +#include +#include +#include +using namespace std; +#define lli long long int +#define Min(a,b) (a 0){ + sum += T[index] ; + index = index - (index&(-1*index)); + } + return sum ; +} +void update(lli T[] , lli n , lli index , lli value ){ + index++; + while(index <= n){ + T[index] += value ; + index = index + (index&(-1*index)); + } +} +lli * binary_indexed_tree(lli n){ + lli i ; + lli* T =(lli *) malloc(sizeof(lli)*200002) ; + for(i = 1 ; i <= n+1 ; i++) + { + T[i] = 0 ; + } + // for(i = 0 ; i < n ; i++) + // { + // update(T,n,i,a[i]) ; + // } + return T ; +} +int main() { + lli test,n,i,j,query,option,ans,p,q,v; + lli arr[200002]; + cin>>test; + while(test--) + { + cin>>n; + cin>>query; + fr(i,0,n) + { + arr[i] = 0; + } + lli* T1 = binary_indexed_tree(n); + lli* T2 = binary_indexed_tree(n); + while(query--) + { + cin>>option>>p>>q ; + p--; + q--; + if(option == 0) + { + cin>>v; + update(T1,n,p,v); + update(T1,n,q+1,-v); + update(T2,n,p,v*(p-1)); + update(T2,n,q+1,-v*q); + } + else + { + ans = sum(T1,q)*q-sum(T2,q)-sum(T1,p-1)*(p-1)+sum(T2,p-1) ; + cout< Date: Wed, 4 Nov 2015 02:09:08 +0530 Subject: [PATCH 04/32] Reference File Added Resources for detailed Learning. --- binaryIndexedTree/Reference.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 binaryIndexedTree/Reference.txt diff --git a/binaryIndexedTree/Reference.txt b/binaryIndexedTree/Reference.txt new file mode 100644 index 000000000..e7a6004fd --- /dev/null +++ b/binaryIndexedTree/Reference.txt @@ -0,0 +1,3 @@ +Here are some websites/blogs which inspired and motivated this concept in me. +https://kartikkukreja.wordpress.com/2013/12/02/range-updates-with-bit-fenwick-tree/ +http://zobayer.blogspot.in/2013/11/various-usage-of-bit.html From 40b4084c7158da2777f07d06d116f431c28a81c8 Mon Sep 17 00:00:00 2001 From: Mayank Date: Wed, 2 Dec 2015 01:24:08 +0530 Subject: [PATCH 05/32] Shortest Path Algorithms added --- Shortest_Path/Floyd-Warshall/a.out | Bin 0 -> 13584 bytes .../Floyd-Warshall/floyd_warshall.cpp | 57 +++++ Shortest_Path/dijsktra/a.out | Bin 0 -> 33192 bytes .../dijsktra/dijsktra_implementation.cpp | 230 ++++++++++++++++++ binaryIndexedTree/SPOJ_ctrick.cpp | 116 +++++++++ 5 files changed, 403 insertions(+) create mode 100755 Shortest_Path/Floyd-Warshall/a.out create mode 100644 Shortest_Path/Floyd-Warshall/floyd_warshall.cpp create mode 100755 Shortest_Path/dijsktra/a.out create mode 100644 Shortest_Path/dijsktra/dijsktra_implementation.cpp create mode 100644 binaryIndexedTree/SPOJ_ctrick.cpp diff --git a/Shortest_Path/Floyd-Warshall/a.out b/Shortest_Path/Floyd-Warshall/a.out new file mode 100755 index 0000000000000000000000000000000000000000..162a7202c3524a91bb5bbb22b6a15d741f901308 GIT binary patch literal 13584 zcmeHOe{5UVb-pBJTZtV?a_vNp8=Fy`)=n!{lx0m$u!NLE`6-ZXRg#k|jq^m2l*NV; z1@h66gJzW>D+{5jbF*ep(*!fNVF-qz&4#pa(;}8^FLJQ}Q#+&$wyZGPBp?%aa9c0a zQYYMZ?z@M4d?F1m!~Pj`g~xNxch5QZ-t*r5_1@7}f<0YMheL33ihBfclhu9+nZH7u zY?Q3R+QbdQFSd!TVl9w0xcst&sF`EBtV}blR&p-TDqL+&6KHe#Wrpb|O;|AH780fU zipj6CCf!kIvP^~WNPzUHt;@Gb7IaW%m_DW2F;9(>$s>OWCcXM?k_8=<8KxIi!mes=3ae|zwyzna{;naXa$#rI8!T0EwkB<2QA?n(XmI_K>l zU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warshall.cpp new file mode 100644 index 000000000..24e6cb3a2 --- /dev/null +++ b/Shortest_Path/Floyd-Warshall/floyd_warshall.cpp @@ -0,0 +1,57 @@ +#include +using namespace std; +#define lli long long int +#define infinite numeric_limits::max() +#define Min(a,b) ((a)<(b)?(a):(b)) +#define Max(a,b) ((a)>(b)?(a):(b)) +#define fr(i,j,s) for(i = j ; i < s ; i++) +#define ifr(i,j,s) for(i = j ; i >= s , i--) +void floydWasrshall(lli G[][400],int V) +{ + int u , v , w; + fr(u,0,V) + { + fr(v,0,V) + { + fr(w,0,V) + { + if(G[v][u]+G[u][w] < G[v][w]) + G[v][w] = G[v][u]+G[u][w] ; + } + } + } +} +int main(void) +{ + int test,v,e,a,b,i,j; + lli wt; + cin>>v>>e; + int ed = 0; + lli graph[400][400]; + int temp = e ; + fr(i,0,v) + { + fr(j,0,v) + { + graph[i][j] = infinite ; + if(i==j) + graph[i][j] = 0; + } + } + while(e--) + { + cin>>a>>b>>wt; + graph[a-1][b-1] = wt; + } + lli q ; + cin>>q; + floydWasrshall(graph,v); + while(q--) + { + cin>>a>>b; + if(graph[a-1][b-1] == infinite ) + graph[a-1][b-1] = -1 ; + cout<hFD? z@AG{B=+T_D_u6Z%z4qE`uf5OShcnx~OBdM;Ls^$i%~O&aSRp8VSE{?iqEMFaWx-RXXbU<_F?PT-{LQjy#4KBdBrG^eqm>0M4GCFa;;Jx{8pej} ztOXTx}o%8WWA7FX@ zsJ8v>4*Qnal|E5>?Cz>alw~>iv-(XbC)_k&aD#!T{OC;sY-9iR(ZGq`-!2_` z%b*27^?Q{=(2zb#DaX|ZeoR03*MaX#PIEu@?*l_)#=g z7d-oH`c9eh`x}~DBK~MB&=&LimA`tke?_Pv9F2wA7BmH-(NI+Rt5z=a*M-_l^vY!m znpz^Em4S^-AzjvY$py=6W3$37QUAt3G&H>`5{@k_^=?*v;9Hua-kL=#YFldkUO|N0 zqTUr@Bx_^SLy@|ss$gxbv^3ZlX!FO~0^wM+D(LmD0B#zDg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3eIHPWlrPS8nj@FlYi6CVQ6|eRLaX8y9KFY0t zz7IjT&)9SK+V976Tf*&9pPu25Nxu`B=v-`s!I|_AV5T-J<#0f@^Gx@*em*mmrT^W} z|Lsp}_Nt+ey^)YSxawU6j_n>(!T&15CjaUSmLr#iKa1abem-I%4wwzb8**YNi@(5>vKkOekvPBgoV~+T)cS6>NiH(1 zG~q?~<2SRd`mN{jiL4Np)qYEVi_U_ZK*MivTY2lby~gCP5h?ikDj;br{Y|vG6bY(o z@$b*5kfQx2zfW>_pWcKPzt#R-z>|NzS>A2(cboh!(|+XVGhizJwZM_YB#-YGI84IS zCtKE)e03s|%x~>0l$iWSl8KRant2P}n8I&8U*Lzp<@z<1PP!~U3w0|J$@N?N6t9^7 zhQbtMk&CV386@`OkNlSXt^JInCckADkjRzV{=0!q=C}4etl!zb$KDnI}AR5HJ{ zKXS`3&GDwCm?^;OKTF<0B=9!9i~-`T=fzXzRzj-1Qu$v35B{Z4oZos5b(mWYsr0G& z*TGBuIR<%I`!dci$^RC3Xk&}t+P^6<`HxaKE~_7``mJ`oi?ZbUt$m(T=GKTsFG6s$ z@)kUi!XMuca%qkZ4dQo;&w?MJB)NX;`MblVSu8y*0T!Q?{}c)0toHABZIGg?T>|32 zW3O{cnP@AkxY5JE4rr)aiQ$ESThuu0jv<&8ThmO$BO?fwtPo(==+|ihHL(f G{r(S(;oz(Q literal 0 HcmV?d00001 diff --git a/Shortest_Path/dijsktra/dijsktra_implementation.cpp b/Shortest_Path/dijsktra/dijsktra_implementation.cpp new file mode 100644 index 000000000..d2d0025f5 --- /dev/null +++ b/Shortest_Path/dijsktra/dijsktra_implementation.cpp @@ -0,0 +1,230 @@ +#include +using namespace std; +#define lli long long int +#define infinite 0xffff +#define Min(a,b) ((a)<(b)?(a):(b)) +#define Max(a,b) ((a)>(b)?(a):(b)) +#define fr(i,j,s) for(i = j ; i < s ; i++) +#define ifr(i,j,s) for(i = j ; i >= s , i--) +struct adjListNode +{ + int dest; + int wt; + struct adjListNode *next; +}; +struct adjList +{ + struct adjListNode *head; +}; +struct Graph +{ + int V ; + struct adjList *array; +}; +struct adjListNode * newAdjNode(int dest, int wt) +{ + struct adjListNode *newNode = (struct adjListNode* )malloc(sizeof(struct adjListNode)); + newNode->dest = dest; + newNode->wt = wt; + newNode->next = NULL ; + return newNode; +} +struct Graph* createGraph(int V,int E) +{ + int i ; + struct Graph* G = (struct Graph *)malloc(sizeof(struct Graph)); + G->V = V ; + G->array = (struct adjList*)malloc(E*sizeof(struct adjList)); + fr(i,0,V) + { + G->array[i].head = NULL ; + } + return G ; +} +void addEdge(struct Graph *G,int src, int dest, int wt) +{ + struct adjListNode*temp=newAdjNode(dest,wt); + temp->next=G->array[src].head; + G->array[src].head=temp; + + temp=newAdjNode(src,wt); + temp->next=G->array[dest].head; + G->array[dest].head=temp; +} +struct MinHeapNode +{ + int v; + int dist; +}; +struct MinHeap +{ + int size; + int capacity; + int *pos; + struct MinHeapNode **array; +}; +struct MinHeapNode* newMinHeapNode(int v, int dist) +{ + struct MinHeapNode* minHeapNode = + (struct MinHeapNode*) malloc(sizeof(struct MinHeapNode)); + minHeapNode->v = v; + minHeapNode->dist = dist; + return minHeapNode; +} +struct MinHeap* createMinHeap(int capacity) +{ + struct MinHeap* minHeap = + (struct MinHeap*) malloc(sizeof(struct MinHeap)); + minHeap->pos = (int *)malloc(capacity * sizeof(int)); + minHeap->size = 0; + minHeap->capacity = capacity; + minHeap->array = + (struct MinHeapNode**) malloc(capacity * sizeof(struct MinHeapNode*)); + return minHeap; +} +void swapMinHeapNode(struct MinHeapNode** a, struct MinHeapNode** b) +{ + struct MinHeapNode* t = *a; + *a = *b; + *b = t; +} +void minHeapify(struct MinHeap* minHeap, int idx) +{ + int smallest, left, right; + smallest = idx; + left = 2 * idx + 1; + right = 2 * idx + 2; + + if (left < minHeap->size && + minHeap->array[left]->dist < minHeap->array[smallest]->dist ) + smallest = left; + + if (right < minHeap->size && + minHeap->array[right]->dist < minHeap->array[smallest]->dist ) + smallest = right; + + if (smallest != idx) + { + MinHeapNode *smallestNode = minHeap->array[smallest]; + MinHeapNode *idxNode = minHeap->array[idx]; + + minHeap->pos[smallestNode->v] = idx; + minHeap->pos[idxNode->v] = smallest; + + swapMinHeapNode(&minHeap->array[smallest], &minHeap->array[idx]); + + minHeapify(minHeap, smallest); + } +} + +int isEmpty(struct MinHeap* minHeap) +{ + return minHeap->size == 0; +} + +struct MinHeapNode* extractMin(struct MinHeap* minHeap) +{ + if (isEmpty(minHeap)) + return NULL; + + struct MinHeapNode* root = minHeap->array[0]; + + struct MinHeapNode* lastNode = minHeap->array[minHeap->size - 1]; + minHeap->array[0] = lastNode; + + minHeap->pos[root->v] = minHeap->size-1; + minHeap->pos[lastNode->v] = 0; + + --minHeap->size; + minHeapify(minHeap, 0); + + return root; +} + +void decreaseKey(struct MinHeap* minHeap, int v, int dist) +{ + int i = minHeap->pos[v]; + + minHeap->array[i]->dist = dist; + + while (i && minHeap->array[i]->dist < minHeap->array[(i - 1) / 2]->dist) + { + minHeap->pos[minHeap->array[i]->v] = (i-1)/2; + minHeap->pos[minHeap->array[(i-1)/2]->v] = i; + swapMinHeapNode(&minHeap->array[i], &minHeap->array[(i - 1) / 2]); + i = (i - 1) / 2; + } +} + +bool isInMinHeap(struct MinHeap *minHeap, int v) +{ + if (minHeap->pos[v] < minHeap->size) + return true; + return false; +} +void printarr(int dist[], int v , int src) +{ + int i ; + fr(i,0,v) + { + if(i==src) + continue; + if(dist[i] == infinite) + dist[i] = -1 ; + cout<V; + int dist[V]; + struct MinHeap * minHeap = createMinHeap(V); + fr(i,0,V) + { + dist[i] = infinite ; + minHeap->array[i] = newMinHeapNode(i,dist[i]); + minHeap->pos[i] = i ; + } + minHeap->array[src] = newMinHeapNode(src,dist[src]) ; + minHeap->pos[src] = src ; + dist[src] = 0 ; + decreaseKey(minHeap,src,dist[src]); + minHeap->size = V ; + while(!isEmpty(minHeap)) + { + struct MinHeapNode* minHeapNode = extractMin(minHeap); + int u = minHeapNode->v; + struct adjListNode* pCrawl = G->array[u].head; + while (pCrawl != NULL) + { + int v = pCrawl->dest; + if (isInMinHeap(minHeap, v) && dist[u] != INT_MAX && pCrawl->wt + dist[u] < dist[v]) + { + dist[v] = dist[u] + pCrawl->wt; + decreaseKey(minHeap, v, dist[v]); + } + pCrawl = pCrawl->next; + } + } + printarr(dist,V,src); +} +int main(void) +{ + int test,v,e,a,b,wt; + cin>>test; + while(test--) + { + cin>>v>>e; + struct Graph* G = createGraph(v,e); + while(e--) + { + cin>>a>>b>>wt; + addEdge(G,a-1,b-1,wt); + } + cin>>a; + dijsktra(G,a-1); + } + return 0; +} \ No newline at end of file diff --git a/binaryIndexedTree/SPOJ_ctrick.cpp b/binaryIndexedTree/SPOJ_ctrick.cpp new file mode 100644 index 000000000..54660c92a --- /dev/null +++ b/binaryIndexedTree/SPOJ_ctrick.cpp @@ -0,0 +1,116 @@ +#include +#include +#include +#include +#include +using namespace std; +#define lli long long int +#define Min(a,b) (a 0){ + sum += T[index] ; + index = index - (index&(-1*index)); + } + return sum ; +} +void update(lli T[] , lli n , lli index , lli value ){ + index++; + while(index <= n){ + T[index] += value ; + index = index + (index&(-1*index)); + } +} +lli * binary_indexed_tree(lli n){ + lli i ; + lli* T =(lli *) malloc(sizeof(lli)*200002) ; + for(i = 1 ; i <= n+1 ; i++) + { + T[i] = 0 ; + } + for(i = 0 ; i < n ; i++) + { + update(T,n,i,1) ; + } + return T ; +} +void renew(lli* T,lli n) +{ + lli i ; + for(i = 1 ; i <= n+1 ; i++) + { + T[i] = 0 ; + } + for(i = 0 ; i < n ; i++) + { + update(T,n,i,1) ; + } +} + +lli modified_binary_search(lli * T, lli val, lli start , lli end) +{ + lli mid = (start+end)/2 ; + lli mid_sum = sum(T,mid) ; + if((mid_sum == val)&&(hash_array_mod[mid+1] == 0)) + return mid; + else if( (mid_sum > val) || ((mid_sum == val)&&(hash_array_mod[mid+1] != 0)) ) + { + return modified_binary_search(T,val,start,mid-1); + } + else + { + return modified_binary_search(T,val,mid+1,end); + } +} +int main() { + lli test,n,i,j,ans,current_pos,next_pos_sum,next_pos,count,free_space_total; + lli a[200002]; + cin>>test; + lli* T = binary_indexed_tree(n); + while(test--) + { + cin>>n; + //cin>>query; + if(n == 1) + { + cout<<"1"< Date: Wed, 2 Dec 2015 01:33:02 +0530 Subject: [PATCH 06/32] Adding Minimum Spanning Tree Algos --- Minimum_Spanning_Tree/KruskalMST.cpp | 107 +++++++++++++ Minimum_Spanning_Tree/Prims.cpp | 225 +++++++++++++++++++++++++++ Minimum_Spanning_Tree/a.out | Bin 0 -> 53424 bytes 3 files changed, 332 insertions(+) create mode 100644 Minimum_Spanning_Tree/KruskalMST.cpp create mode 100644 Minimum_Spanning_Tree/Prims.cpp create mode 100755 Minimum_Spanning_Tree/a.out diff --git a/Minimum_Spanning_Tree/KruskalMST.cpp b/Minimum_Spanning_Tree/KruskalMST.cpp new file mode 100644 index 000000000..222e852dd --- /dev/null +++ b/Minimum_Spanning_Tree/KruskalMST.cpp @@ -0,0 +1,107 @@ +#include +using namespace std; +#define lli long long int +#define infinite numeric_limits::max() +#define Min(a,b) ((a)<(b)?(a):(b)) +#define Max(a,b) ((a)>(b)?(a):(b)) +#define fr(i,j,s) for(i = j ; i < s ; i++) +#define ifr(i,j,s) for(i = j ; i >= s , i--) +struct edge +{ + lli wt; + int src; + int dest; +}; +struct Graph +{ + int V; + int E; + struct edge* array; +}; +struct sub +{ + int parent; + int rank; +}; +bool comp(struct edge &a, struct edge &b) +{ + return ((a.wt)<(b.wt)); +} +int find(struct sub subset[], int i) +{ + if(subset[i].parent != i) + { + subset[i].parent = find(subset,subset[i].parent); + } + return subset[i].parent ; +} +void Union(struct sub subset[] , int x, int y) +{ + int xfather = find(subset,x); + int yfather = find(subset,y); + if(subset[xfather].rankV = V ; + G->E = E ; + G->array = (struct edge*)malloc(E*sizeof(struct edge)); + return G ; +} +void KruskalMST(struct Graph *G) +{ + int i ; + int V = G->V ; + int E = G->E ; + lli sum = 0 ; + struct sub subset[G->V]; + fr(i,0,V) + { + subset[i].parent = i ; + subset[i].rank = 0 ; + } + sort(G->array, (G->array)+G->E,comp); + fr(i,0,E) + { + int x = find(subset,G->array[i].src); + int y = find(subset,G->array[i].dest); + if(x==y) + continue; + else + { + Union(subset,G->array[i].src,G->array[i].dest); + sum+=G->array[i].wt; + } + } + cout<>v>>e; + struct Graph* G = createGraph(v,e); + int ed = 0; + int temp = e ; + while(e--) + { + cin>>a>>b>>wt; + G->array[ed].src=a-1; + G->array[ed].dest=b-1; + G->array[ed].wt=wt; + ed++; + } + cin>>a; + KruskalMST(G); + return 0; +} \ No newline at end of file diff --git a/Minimum_Spanning_Tree/Prims.cpp b/Minimum_Spanning_Tree/Prims.cpp new file mode 100644 index 000000000..242040193 --- /dev/null +++ b/Minimum_Spanning_Tree/Prims.cpp @@ -0,0 +1,225 @@ +#include +using namespace std; +#define lli long long int +#define infinite numeric_limits::max() +#define Min(a,b) ((a)<(b)?(a):(b)) +#define Max(a,b) ((a)>(b)?(a):(b)) +#define fr(i,j,s) for(i = j ; i < s ; i++) +#define ifr(i,j,s) for(i = j ; i >= s , i--) +struct adjListNode +{ + int dest; + int wt; + struct adjListNode *next; +}; +struct adjList +{ + struct adjListNode *head; +}; +struct Graph +{ + int V ; + struct adjList *array; +}; +struct adjListNode * newAdjNode(int dest, int wt) +{ + struct adjListNode *newNode = (struct adjListNode* )malloc(sizeof(struct adjListNode)); + newNode->dest = dest; + newNode->wt = wt; + newNode->next = NULL ; + return newNode; +} +struct Graph* createGraph(int V,int E) +{ + int i ; + struct Graph* G = (struct Graph *)malloc(sizeof(struct Graph)); + G->V = V ; + G->array = (struct adjList*)malloc(E*sizeof(struct adjList)); + fr(i,0,V) + { + G->array[i].head = NULL ; + } + return G ; +} +void addEdge(struct Graph *G,int src, int dest, int wt) +{ + struct adjListNode*temp=newAdjNode(dest,wt); + temp->next=G->array[src].head; + G->array[src].head=temp; + + temp=newAdjNode(src,wt); + temp->next=G->array[dest].head; + G->array[dest].head=temp; +} +struct MinHeapNode +{ + int v; + lli dist; +}; +struct MinHeap +{ + int size; + int capacity; + int *pos; + struct MinHeapNode **array; +}; +struct MinHeapNode* newMinHeapNode(int v, lli dist) +{ + struct MinHeapNode* minHeapNode = + (struct MinHeapNode*) malloc(sizeof(struct MinHeapNode)); + minHeapNode->v = v; + minHeapNode->dist = dist; + return minHeapNode; +} +struct MinHeap* createMinHeap(int capacity) +{ + struct MinHeap* minHeap = + (struct MinHeap*) malloc(sizeof(struct MinHeap)); + minHeap->pos = (int *)malloc(capacity * sizeof(int)); + minHeap->size = 0; + minHeap->capacity = capacity; + minHeap->array = + (struct MinHeapNode**) malloc(capacity * sizeof(struct MinHeapNode*)); + return minHeap; +} +void swapMinHeapNode(struct MinHeapNode** a, struct MinHeapNode** b) +{ + struct MinHeapNode* t = *a; + *a = *b; + *b = t; +} +void minHeapify(struct MinHeap* minHeap, int idx) +{ + int smallest, left, right; + smallest = idx; + left = 2 * idx + 1; + right = 2 * idx + 2; + + if (left < minHeap->size && + minHeap->array[left]->dist < minHeap->array[smallest]->dist ) + smallest = left; + + if (right < minHeap->size && + minHeap->array[right]->dist < minHeap->array[smallest]->dist ) + smallest = right; + + if (smallest != idx) + { + MinHeapNode *smallestNode = minHeap->array[smallest]; + MinHeapNode *idxNode = minHeap->array[idx]; + + minHeap->pos[smallestNode->v] = idx; + minHeap->pos[idxNode->v] = smallest; + + swapMinHeapNode(&minHeap->array[smallest], &minHeap->array[idx]); + + minHeapify(minHeap, smallest); + } +} + +int isEmpty(struct MinHeap* minHeap) +{ + return minHeap->size == 0; +} + +struct MinHeapNode* extractMin(struct MinHeap* minHeap) +{ + if (isEmpty(minHeap)) + return NULL; + + struct MinHeapNode* root = minHeap->array[0]; + + struct MinHeapNode* lastNode = minHeap->array[minHeap->size - 1]; + minHeap->array[0] = lastNode; + + minHeap->pos[root->v] = minHeap->size-1; + minHeap->pos[lastNode->v] = 0; + + --minHeap->size; + minHeapify(minHeap, 0); + + return root; +} + +void decreaseKey(struct MinHeap* minHeap, int v, lli dist) +{ + int i = minHeap->pos[v]; + + minHeap->array[i]->dist = dist; + + while (i && minHeap->array[i]->dist < minHeap->array[(i - 1) / 2]->dist) + { + minHeap->pos[minHeap->array[i]->v] = (i-1)/2; + minHeap->pos[minHeap->array[(i-1)/2]->v] = i; + swapMinHeapNode(&minHeap->array[i], &minHeap->array[(i - 1) / 2]); + i = (i - 1) / 2; + } +} + +bool isInMinHeap(struct MinHeap *minHeap, int v) +{ + if (minHeap->pos[v] < minHeap->size) + return true; + return false; +} +void PrimMST(struct Graph*G,int src) +{ + lli i,j; + int V = G->V; + lli dist[V],parent[V],sto[V]; + struct MinHeap * minHeap = createMinHeap(V); + fr(i,0,V) + { + if(i==src) + continue; + parent[i] = -1 ; + sto[i] = -1 ; + dist[i] = infinite ; + minHeap->array[i] = newMinHeapNode(i,dist[i]); + minHeap->pos[i] = i ; + } + dist[src] = 0 ; + minHeap->array[src] = newMinHeapNode(src,dist[src]) ; + minHeap->pos[src] = src ; + minHeap->size = V ; + lli sum=0; + while(!isEmpty(minHeap)) + { + struct MinHeapNode* minHeapNode = extractMin(minHeap); + int u = minHeapNode->v; + struct adjListNode* pCrawl = G->array[u].head; + while (pCrawl != NULL) + { + int v = pCrawl->dest; + if (isInMinHeap(minHeap, v) && (pCrawl->wt < dist[v])) + { + parent[v] = u ; + if(dist[v] != infinite) + sum -= (dist[v]-pCrawl->wt) ; + else + sum+=pCrawl->wt; + dist[v] =pCrawl->wt; + decreaseKey(minHeap, v, dist[v]); + } + pCrawl = pCrawl->next; + } + } + fr(i,0,V) + cout<>v>>e; + struct Graph* G = createGraph(v,e); + while(e--) + { + cin>>a>>b>>wt; + addEdge(G,a-1,b-1,wt); + } + cin>>a; + PrimMST(G,0); + return 0; +} \ No newline at end of file diff --git a/Minimum_Spanning_Tree/a.out b/Minimum_Spanning_Tree/a.out new file mode 100755 index 0000000000000000000000000000000000000000..b763fff5e3ca753728b7e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xW|>h4f5GQ=jW^4KUn{i5pMK6leG~O_ zLZ>&=XVZV@WGMU5*(0DDc$RCHPo`b|Q{&CF-lubn7^u>l<;^mUUjRJqGx1rY(b`&GNKIv9b7b-b`u74?wslNQ zP8H*lMh`;NH7@LzEW?#7eNh#6DfzMzPJutci6q}%__!Bm{7Y6YSnlOQ;Ii}B~9aS785wSA`(r*<64{PTrD9debMdejj&XQflzY?)sub;eA{0%1}b* zNGhtF;)$e`IYCr2BTAa{b9mQ}$KoxG?cS{klFM~FO{-Y4va+Sp?@dTThoH}GP5l$O zFbOy{mekLdZlNVHuupwqF7Zzdz%0W5zuYT# zUmcFfZ_YS^Fcr1>Z&zd1+c&wTNzP=J4*Ph>RmYqWJK0u|>eoO@34VYjpmFlFN#m%O2JF%XEdAA6szzyMOYS{5K=UBszKI{5DS~H2bY8 zmy*?l3A^x#&2P?mJv#qUCW?8oblAY#5s%Gp&SMI&FUx0Pu7c*<o9|G8#ls-V5Ij1{0jWO=6#y^Sqp9L9Pl9Bx8{M+SL`4ZD7 z#*ZKw$5keyh9;kZ?*Sj1-<;!LrSls(4I7is#Q%-}ai;#}ynm<8Z^i+W zzQ6=D>;+``I(dX@@~@0wRDfyu80bR4gcU`7|6Vh^${405CZ-+HPyU)2D#Nq$V!8G$ zYg|A1-J4XtR@3nPlwaIW{yX)C{(%IAC(1uh=TFpM%~h(vRpuZhp?t%~*H8IBzE5Si z`(yMs6v<56>mmfK`L2qobNML6lxr}ICln#1hrXv$_~`WUjKgOZK1LnJ|I Date: Wed, 30 Dec 2015 21:28:01 +0530 Subject: [PATCH 07/32] Longest Common Subsequence and Longest Increasing Subsequence Problems added --- Longest_Common_Subsequence/lcs.cpp | 73 ++++++++++++++++++ Longest_Increasing_Subsequence/a.out | Bin 0 -> 13600 bytes .../lis_n_log_n.cpp | 67 ++++++++++++++++ .../lis_n_squared_sol.cpp | 73 ++++++++++++++++++ 4 files changed, 213 insertions(+) create mode 100644 Longest_Common_Subsequence/lcs.cpp create mode 100755 Longest_Increasing_Subsequence/a.out create mode 100644 Longest_Increasing_Subsequence/lis_n_log_n.cpp create mode 100644 Longest_Increasing_Subsequence/lis_n_squared_sol.cpp diff --git a/Longest_Common_Subsequence/lcs.cpp b/Longest_Common_Subsequence/lcs.cpp new file mode 100644 index 000000000..e931be526 --- /dev/null +++ b/Longest_Common_Subsequence/lcs.cpp @@ -0,0 +1,73 @@ + +#include +using namespace std; +#define lli long long int +#define infinite 0xffff +#define Min(a,b) (((a)<(b))?(a):(b)) +#define Max(a,b) (((a)>(b))?(a):(b)) +#define fr(i,j,s) for(i = j ; i < s ; i++) +#define ifr(i,j,s) for(i = j ; i >= s , i--) +void lcs(char * a, char *b) +{ + lli lena,lenb,i,j,count; + lena=strlen(a); + lenb=strlen(b); + char record[lena+1][lenb+1]; + //Code to generate the map + fr(i,0,lena+1) + { + fr(j,0,lenb+1) + { + if(i==0 || j==0) + { + record[i][j]=0; + } + else if(a[i-1]==b[j-1]) + { + record[i][j]=record[i-1][j-1]+1; + } + else + { + record[i][j] = Max(record[i-1][j],record[i][j-1]); + } + } + } + //Code to find the subsequence + i = lena; + j = lenb; + char sub[record[lena][lenb]]; + lli index = record[i][j]-1; + while( i > 0 && j > 0 ) + { + if(a[i-1]==b[j-1]) + { + sub[index]=a[i-1]; + i--; + j--; + index--; + } + else if(Max(record[i-1][j],record[i][j-1]) == record[i-1][j]) + { + i--; + } + else + { + j--; + } + } + fr(i,0,record[lena][lenb]) + { + cout<>str1; + cin>>str2; + lcs(str1,str2); + return 0; +} \ No newline at end of file diff --git a/Longest_Increasing_Subsequence/a.out b/Longest_Increasing_Subsequence/a.out new file mode 100755 index 0000000000000000000000000000000000000000..4f7b1a9728c0681ce1f6577a88fd744877929a8b GIT binary patch literal 13600 zcmeHOeQ;Y>mA{f4+f7|rDJeM3woyY1NsCp>ae~wAwvrtsPsK@$KT0Xe@ z=_xqf4Y(`XMYt{*K01LJhQJI=fj=<+Fex92l0f4!omscDuwm)$c$n?3+!RP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W_bPJGS;*5Ja-r)x^R=pO{sO@2C&pd_8YH1G(W4=KfK-4zr!|R?DhW-a8kfV literal 0 HcmV?d00001 diff --git a/Longest_Increasing_Subsequence/lis_n_log_n.cpp b/Longest_Increasing_Subsequence/lis_n_log_n.cpp new file mode 100644 index 000000000..931ddcb1a --- /dev/null +++ b/Longest_Increasing_Subsequence/lis_n_log_n.cpp @@ -0,0 +1,67 @@ +#include +using namespace std; +#define lli long long int +#define infinite 0xffff +#define Min(a,b) (((a)<(b))?(a):(b)) +#define Max(a,b) (((a)>(b))?(a):(b)) +#define fr(i,j,s) for(i = j ; i < s ; i++) +#define ifr(i,j,s) for(i = j ; i >= s ; i--) +lli binary_LookUp(lli * record ,lli a , lli len , lli val) +{ + while(len-a > 1) + { + lli m = a + (len-a)/2; + if(record[m]>=val) + { + len = m ; + } + else + { + a = m ; + } + } + return len ; +} +void lis(lli * a, lli n) +{ + lli i,j,count,index; + lli record[n]; + //Code to generate the map + record[0]=a[0]; + lli len = 1 ; + fr(i,1,n) + { + if(a[i] record[len-1]) + { + record[len] = a[i]; + len++; + } + else + { + index=binary_LookUp(record,-1,len-1,a[i]); + record[index] = a[i]; + } + } + cout<>n; + lli a[n]; + fr(i,0,n) + { + cin>>a[i]; + } + lis(a,n); + return 0; +} \ No newline at end of file diff --git a/Longest_Increasing_Subsequence/lis_n_squared_sol.cpp b/Longest_Increasing_Subsequence/lis_n_squared_sol.cpp new file mode 100644 index 000000000..471a6aa33 --- /dev/null +++ b/Longest_Increasing_Subsequence/lis_n_squared_sol.cpp @@ -0,0 +1,73 @@ +#include +using namespace std; +#define lli long long int +#define infinite 0xffff +#define Min(a,b) (((a)<(b))?(a):(b)) +#define Max(a,b) (((a)>(b))?(a):(b)) +#define fr(i,j,s) for(i = j ; i < s ; i++) +#define ifr(i,j,s) for(i = j ; i >= s ; i--) +void lis(lli * a, lli n) +{ + lli i,j,count; + lli record[n]; + //Code to generate the map + fr(i,0,n) + { + record[i] = 0 ; + } + fr(i,0,n) + { + fr(j,0,i) + { + if( (a[i]>a[j]) && (record[i]<(record[j]+1)) ) + { + record[i]=record[j]+1; + } + } + } + lli max = 0; + lli index = 0 ; + fr(i,0,n) + { + //cout<>n; + lli a[n]; + fr(i,0,n) + { + cin>>a[i]; + } + lis(a,n); + return 0; +} \ No newline at end of file From 05da11d2dd58d3e454215f9b3ba80196840523b3 Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Wed, 18 May 2016 17:08:16 +0000 Subject: [PATCH 08/32] Add Gitter badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index efca67af5..b9c91e9f7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # Algorithms + +[![Join the chat at https://gitter.im/codeIIEST/Algorithms](https://badges.gitter.im/codeIIEST/Algorithms.svg)](https://gitter.im/codeIIEST/Algorithms?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) A Repository to store implementation of some of the famous Data Structures and Algorithms (mainly in C/C++/Java/Python) for everyone to learn and contribute. From 7d3e348f86bed6fec9bdc388fa0a9185c30378b3 Mon Sep 17 00:00:00 2001 From: Binayak Ghosh Date: Wed, 18 May 2016 22:44:37 +0530 Subject: [PATCH 09/32] Change the location of gitter chat badge --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b9c91e9f7..ea36f3961 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # Algorithms +A Repository to store implementation of some of the famous Data Structures and Algorithms (mainly in C/C++/Java/Python) for everyone to learn and contribute. + +
[![Join the chat at https://gitter.im/codeIIEST/Algorithms](https://badges.gitter.im/codeIIEST/Algorithms.svg)](https://gitter.im/codeIIEST/Algorithms?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -A Repository to store implementation of some of the famous Data Structures and Algorithms (mainly in C/C++/Java/Python) for everyone to learn and contribute. From 9af37b002a15350ee9e0f149c9ff08b3027ffd3e Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Mon, 24 Oct 2016 22:40:42 +0530 Subject: [PATCH 10/32] Create READMEDijkstra.md Added a wiki for Dijkstra's Algorithm --- Shortest_Path/dijsktra/READMEDijkstra.md | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Shortest_Path/dijsktra/READMEDijkstra.md diff --git a/Shortest_Path/dijsktra/READMEDijkstra.md b/Shortest_Path/dijsktra/READMEDijkstra.md new file mode 100644 index 000000000..13bc946ff --- /dev/null +++ b/Shortest_Path/dijsktra/READMEDijkstra.md @@ -0,0 +1,62 @@ +## Dijkstra's Algorithm +--------------------------------- +--------------------------------- +![](http://cacm.acm.org/system/assets/0000/3432/072010_CACMpg41_An-Interview.large.jpg?1476779421&1279552189) + +Edsger W.Dijkstra + +------------------------------------ +Dijkstra thought about the shortest path problem when working at the Mathematical Center in Amsterdam in 1956 as a programmer to demonstrate capabilities of a new computer called ARMAC. His objective was to choose both a problem as well as an answer (that would be produced by computer) that non-computing people could understand. He designed the shortest path algorithm and later implemented it for ARMAC for a slightly simplified transportation map of 64 cities in the Netherlands (64, so that 6 bits would be sufficient to encode the city number). + A year later, he came across another problem from hardware engineers working on the institute's next computer: minimize the amount of wire needed to connect the pins on the back panel of the machine. As a solution, he re-discovered the algorithm known as Prim's minimal spanning tree algorithm (known earlier to Jarník, and also rediscovered by Prim). + Dijkstra published the algorithm in 1959, two years after Prim and 29 years after Jarník. + + + **Algorithm** + + Let the node at which we are starting be called the initial node. Let the distance of node Y be the distance from the initial node to Y. Dijkstra's algorithm will assign some initial distance values and will try to improve them step by step. + +Assign to every node a tentative distance value: set it to zero for our initial node and to infinity for all other nodes. +Set the initial node as current. Mark all other nodes unvisited. Create a set of all the unvisited nodes called the unvisited set. +For the current node, consider all of its unvisited neighbors and calculate their tentative distances. Compare the newly calculated tentative distance to the current assigned value and assign the smaller one. For example, if the current node A is marked with a distance of 6, and the edge connecting it with a neighbor B has length 2, then the distance to B (through A) will be 6 + 2 = 8. If B was previously marked with a distance greater than 8 then change it to 8. Otherwise, keep the current value. +When we are done considering all of the neighbors of the current node, mark the current node as visited and remove it from the unvisited set. A visited node will never be checked again. +If the destination node has been marked visited (when planning a route between two specific nodes) or if the smallest tentative distance among the nodes in the unvisited set is infinity (when planning a complete traversal; occurs when there is no connection between the initial node and remaining unvisited nodes), then stop. The algorithm has finished. +Otherwise, select the unvisited node that is marked with the smallest tentative distance, set it as the new "current node", and go back to step 3. + +![](https://upload.wikimedia.org/wikipedia/commons/5/57/Dijkstra_Animation.gif) + +**A simple gif to demonstrate the algo** + + +--------------------------------------------------- + +##Related Problems +The functionality of Dijkstra's original algorithm can be extended with a variety of modifications. For example, sometimes it is desirable to present solutions which are less than mathematically optimal. To obtain a ranked list of less-than-optimal solutions, the optimal solution is first calculated. A single edge appearing in the optimal solution is removed from the graph, and the optimum solution to this new graph is calculated. Each edge of the original solution is suppressed in turn and a new shortest-path calculated. The secondary solutions are then ranked and presented after the first optimal solution. + +Dijkstra's algorithm is usually the working principle behind link-state routing protocols, OSPF and IS-IS being the most common ones. + +Unlike Dijkstra's algorithm, the Bellman–Ford algorithm can be used on graphs with negative edge weights, as long as the graph contains no negative cycle reachable from the source vertex s. The presence of such cycles means there is no shortest path, since the total weight becomes lower each time the cycle is traversed. It is possible to adapt Dijkstra's algorithm to handle negative weight edges by combining it with the Bellman-Ford algorithm (to remove negative edges and detect negative cycles), such an algorithm is called Johnson's algorithm. + +The A* algorithm is a generalization of Dijkstra's algorithm that cuts down on the size of the subgraph that must be explored, if additional information is available that provides a lower bound on the "distance" to the target. This approach can be viewed from the perspective of linear programming: there is a natural linear program for computing shortest paths, and solutions to its dual linear program are feasible if and only if they form a consistent heuristic (speaking roughly, since the sign conventions differ from place to place in the literature). This feasible dual / consistent heuristic defines a non-negative reduced cost and A* is essentially running Dijkstra's algorithm with these reduced costs. If the dual satisfies the weaker condition of admissibility, then A* is instead more akin to the Bellman–Ford algorithm. + +The process that underlies Dijkstra's algorithm is similar to the greedy process used in Prim's algorithm. Prim's purpose is to find a minimum spanning tree that connects all nodes in the graph; Dijkstra is concerned with only two nodes. Prim's does not evaluate the total weight of the path from the starting node, only the individual path. + +Breadth-first search can be viewed as a special-case of Dijkstra's algorithm on unweighted graphs, where the priority queue degenerates into a FIFO queue. + +Fast marching method can be viewed as a continuous version of Dijkstra's algorithm which computes the geodesic distance on a triangle mesh. + + +---------------------------------------------------------- + +##Applications + +1. **Flight Agenda** -- A travel agent requests software for making an agenda of flights for clients. The agent has access to a data base with all airports and flights. Besides the flight number, origin airport and destination, the flights have departure and arrival time. Specifically the agent wants to determine the earliest arrival time for the destination given an origin airport and start time + +2. **Telephone Network** -- In a telephone network the lines have bandwidth, BW. We want to route the phone call via the highest BW. + + + ---------------------------------------------- + **Source** + + [Wikipedia](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) + + [Dijkstra](http://www.csl.mtu.edu/cs2321/www/newLectures/30_More_Dijkstra.htm) From 8b5f426dc1f509440dd87007665aaa3e63c45db9 Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Tue, 25 Oct 2016 11:47:25 +0530 Subject: [PATCH 11/32] Create rsa.c Adding solution for RSA algorithm --- Cryptography_Algorithm/RSA_Algorithm/rsa.c | 140 +++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Cryptography_Algorithm/RSA_Algorithm/rsa.c diff --git a/Cryptography_Algorithm/RSA_Algorithm/rsa.c b/Cryptography_Algorithm/RSA_Algorithm/rsa.c new file mode 100644 index 000000000..b19b520b8 --- /dev/null +++ b/Cryptography_Algorithm/RSA_Algorithm/rsa.c @@ -0,0 +1,140 @@ +#include +#include +#include +#include + +long int p,q,n,t,flag,e[100],d[100],temp[100],j,m[100],en[100],i; +char msg[100]; +int prime(long int); +void ce(); +long int cd(long int); +void encrypt(); +void decrypt(); +int main() +{ + printf("\nENTER FIRST PRIME NUMBER\n"); + scanf("%ld",&p); + flag=prime(p); + if(flag==0) + { + printf("\nWRONG INPUT\n"); + exit(1); + } + printf("\nENTER ANOTHER PRIME NUMBER\n"); + scanf("%ld",&q); + flag=prime(q); + if(flag==0||p==q) + { + printf("\nWRONG INPUT\n"); + exit(1); + } + printf("\nENTER MESSAGE\n"); + fflush(stdin); + scanf("%s",msg); + for(i=0;msg[i]!=NULL;i++) + m[i]=msg[i]; + n=p*q; + t=(p-1)*(q-1); + ce(); + printf("\nPOSSIBLE VALUES OF e AND d ARE\n"); + for(i=0;i0) + { + d[k]=flag; + k++; + } + if(k==99) + break; + } + } +} + +long int cd(long int x) +{ + long int k=1; + while(1) + { + k=k+t; + if(k%x==0) + return(k/x); + } +} + +void encrypt() +{ + long int pt,ct,key=e[0],k,len; + i=0; + len=strlen(msg); + while(i!=len) + { + pt=m[i]; + pt=pt-96; + k=1; + for(j=0;j Date: Sun, 25 Dec 2016 09:04:41 +0530 Subject: [PATCH 12/32] Deleting rsa.c --- Cryptography_Algorithm/RSA_Algorithm/rsa.c | 140 --------------------- 1 file changed, 140 deletions(-) delete mode 100644 Cryptography_Algorithm/RSA_Algorithm/rsa.c diff --git a/Cryptography_Algorithm/RSA_Algorithm/rsa.c b/Cryptography_Algorithm/RSA_Algorithm/rsa.c deleted file mode 100644 index b19b520b8..000000000 --- a/Cryptography_Algorithm/RSA_Algorithm/rsa.c +++ /dev/null @@ -1,140 +0,0 @@ -#include -#include -#include -#include - -long int p,q,n,t,flag,e[100],d[100],temp[100],j,m[100],en[100],i; -char msg[100]; -int prime(long int); -void ce(); -long int cd(long int); -void encrypt(); -void decrypt(); -int main() -{ - printf("\nENTER FIRST PRIME NUMBER\n"); - scanf("%ld",&p); - flag=prime(p); - if(flag==0) - { - printf("\nWRONG INPUT\n"); - exit(1); - } - printf("\nENTER ANOTHER PRIME NUMBER\n"); - scanf("%ld",&q); - flag=prime(q); - if(flag==0||p==q) - { - printf("\nWRONG INPUT\n"); - exit(1); - } - printf("\nENTER MESSAGE\n"); - fflush(stdin); - scanf("%s",msg); - for(i=0;msg[i]!=NULL;i++) - m[i]=msg[i]; - n=p*q; - t=(p-1)*(q-1); - ce(); - printf("\nPOSSIBLE VALUES OF e AND d ARE\n"); - for(i=0;i0) - { - d[k]=flag; - k++; - } - if(k==99) - break; - } - } -} - -long int cd(long int x) -{ - long int k=1; - while(1) - { - k=k+t; - if(k%x==0) - return(k/x); - } -} - -void encrypt() -{ - long int pt,ct,key=e[0],k,len; - i=0; - len=strlen(msg); - while(i!=len) - { - pt=m[i]; - pt=pt-96; - k=1; - for(j=0;j Date: Sun, 25 Dec 2016 09:09:41 +0530 Subject: [PATCH 13/32] Create rsa.py RSA algorithm implemented in python --- Cryptography/RSA_Algorithm/rsa.py | 116 ++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 Cryptography/RSA_Algorithm/rsa.py diff --git a/Cryptography/RSA_Algorithm/rsa.py b/Cryptography/RSA_Algorithm/rsa.py new file mode 100644 index 000000000..d4d764752 --- /dev/null +++ b/Cryptography/RSA_Algorithm/rsa.py @@ -0,0 +1,116 @@ +import random + + +''' +Euclid's algorithm for determining the greatest common divisor +Use iteration to make it faster for larger integers +''' +def gcd(a, b): + while b != 0: + a, b = b, a % b + return a + +''' +Euclid's extended algorithm for finding the multiplicative inverse of two numbers +''' +def multiplicative_inverse(e, phi): + d = 0 + x1 = 0 + x2 = 1 + y1 = 1 + temp_phi = phi + + while e > 0: + temp1 = temp_phi/e + temp2 = temp_phi - temp1 * e + temp_phi = e + e = temp2 + + x = x2- temp1* x1 + y = d - temp1 * y1 + + x2 = x1 + x1 = x + d = y1 + y1 = y + + if temp_phi == 1: + return d + phi + +''' +Tests to see if a number is prime. +''' +def is_prime(num): + if num == 2: + return True + if num < 2 or num % 2 == 0: + return False + for n in xrange(3, int(num**0.5)+2, 2): + if num % n == 0: + return False + return True + +def generate_keypair(p, q): + if not (is_prime(p) and is_prime(q)): + raise ValueError('Both numbers must be prime.') + elif p == q: + raise ValueError('p and q cannot be equal') + #n = pq + n = p * q + + #Phi is the totient of n + # n number theory, Euler's totient function counts the positive integers up to a given integer n that are relatively prime to n. + phi = (p-1) * (q-1) + + #Choose an integer e such that e and phi(n) are coprime + e = random.randrange(1, phi) + + #Use Euclid's Algorithm to verify that e and phi(n) are comprime + + g = gcd(e, phi) + while g != 1: + e = random.randrange(1, phi) + g = gcd(e, phi) + + #Use Extended Euclid's Algorithm to generate the private key + + d = multiplicative_inverse(e, phi) + + #Return public and private keypair + #Public key is (e, n) and private key is (d, n) + return ((e, n), (d, n)) + +def encrypt(pk, plaintext): + #Unpack the key into it's components + key, n = pk + #Convert each letter in the plaintext to numbers based on the character using a^b mod m + cipher = [(ord(char) ** key) % n for char in plaintext] + #Return the array of bytes + return cipher + +def decrypt(pk, ciphertext): + #Unpack the key into its components + key, n = pk + #Generate the plaintext based on the ciphertext and key using a^b mod m + plain = [chr((char ** key) % n) for char in ciphertext] + #Return the array of bytes as a string + return ''.join(plain) + + +if __name__ == '__main__': + ''' + Detect if the script is being run directly by the user + ''' + print "RSA Encrypter/ Decrypter" + p = int(raw_input("Enter a prime number (17, 19, 23, etc): ")) + q = int(raw_input("Enter another prime number (Not one you entered above): ")) + print "Generating your public/private keypairs now . . ." + public, private = generate_keypair(p, q) + print "Your public key is ", public ," and your private key is ", private + message = raw_input("Enter a message to encrypt with your private key: ") + encrypted_msg = encrypt(private, message) + print "Your encrypted message is: " + print ''.join(map(lambda x: str(x), encrypted_msg)) + print "Decrypting message with public key ", public ," . . ." + print "Your message is:" + print decrypt(public, encrypted_msg) From d01ab81da9a5f8b38a46d1d96235e5d3589c258e Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Sun, 25 Dec 2016 09:14:17 +0530 Subject: [PATCH 14/32] Create rsa.py RSA Algorithm implemented in python --- Cryptography/RSA_Algortihm/rsa.py | 113 ++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 Cryptography/RSA_Algortihm/rsa.py diff --git a/Cryptography/RSA_Algortihm/rsa.py b/Cryptography/RSA_Algortihm/rsa.py new file mode 100644 index 000000000..3199e6bfc --- /dev/null +++ b/Cryptography/RSA_Algortihm/rsa.py @@ -0,0 +1,113 @@ +import random + + +''' +Euclid's algorithm for determining the greatest common divisor +Use iteration to make it faster for larger integers +''' +def gcd(a, b): + while b != 0: + a, b = b, a % b + return a + +''' +Euclid's extended algorithm for finding the multiplicative inverse of two numbers +''' +def multiplicative_inverse(e, phi): + d = 0 + x1 = 0 + x2 = 1 + y1 = 1 + temp_phi = phi + + while e > 0: + temp1 = temp_phi/e + temp2 = temp_phi - temp1 * e + temp_phi = e + e = temp2 + + x = x2- temp1* x1 + y = d - temp1 * y1 + + x2 = x1 + x1 = x + d = y1 + y1 = y + + if temp_phi == 1: + return d + phi + +''' +Tests to see if a number is prime. +''' +def is_prime(num): + if num == 2: + return True + if num < 2 or num % 2 == 0: + return False + for n in xrange(3, int(num**0.5)+2, 2): + if num % n == 0: + return False + return True + +def generate_keypair(p, q): + if not (is_prime(p) and is_prime(q)): + raise ValueError('Both numbers must be prime.') + elif p == q: + raise ValueError('p and q cannot be equal') + #n = pq + n = p * q + + #Phi is the totient of n + phi = (p-1) * (q-1) + + #Choose an integer e such that e and phi(n) are coprime + e = random.randrange(1, phi) + + #Use Euclid's Algorithm to verify that e and phi(n) are comprime + g = gcd(e, phi) + while g != 1: + e = random.randrange(1, phi) + g = gcd(e, phi) + + #Use Extended Euclid's Algorithm to generate the private key + d = multiplicative_inverse(e, phi) + + #Return public and private keypair + #Public key is (e, n) and private key is (d, n) + return ((e, n), (d, n)) + +def encrypt(pk, plaintext): + #Unpack the key into it's components + key, n = pk + #Convert each letter in the plaintext to numbers based on the character using a^b mod m + cipher = [(ord(char) ** key) % n for char in plaintext] + #Return the array of bytes + return cipher + +def decrypt(pk, ciphertext): + #Unpack the key into its components + key, n = pk + #Generate the plaintext based on the ciphertext and key using a^b mod m + plain = [chr((char ** key) % n) for char in ciphertext] + #Return the array of bytes as a string + return ''.join(plain) + + +if __name__ == '__main__': + ''' + Detect if the script is being run directly by the user + ''' + print "RSA Encrypter/ Decrypter" + p = int(raw_input("Enter a prime number (17, 19, 23, etc): ")) + q = int(raw_input("Enter another prime number (Not one you entered above): ")) + print "Generating your public/private keypairs now . . ." + public, private = generate_keypair(p, q) + print "Your public key is ", public ," and your private key is ", private + message = raw_input("Enter a message to encrypt with your private key: ") + encrypted_msg = encrypt(private, message) + print "Your encrypted message is: " + print ''.join(map(lambda x: str(x), encrypted_msg)) + print "Decrypting message with public key ", public ," . . ." + print "Your message is:" + print decrypt(public, encrypted_msg) From 4924f1259f12639419a3f82453140d95537f7c7a Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Sun, 25 Dec 2016 09:26:56 +0530 Subject: [PATCH 15/32] Update README.md --- README.md | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/README.md b/README.md index ea36f3961..f58a3ac6b 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,167 @@ A Repository to store implementation of some of the famous Data Structures and A
[![Join the chat at https://gitter.im/codeIIEST/Algorithms](https://badges.gitter.im/codeIIEST/Algorithms.svg)](https://gitter.im/codeIIEST/Algorithms?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + + + + +## Sort Algorithms + + +### Bubble +![alt text][bubble-image] + +From [Wikipedia][bubble-wiki]: Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. + +__Properties__ +* Worst case performance O(n^2) +* Best case performance O(n) +* Average case performance O(n^2) + +###### View the algorithm in [action][bubble-toptal] + + + +### Insertion +![alt text][insertion-image] + +From [Wikipedia][insertion-wiki]: Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. + +__Properties__ +* Worst case performance O(n^2) +* Best case performance O(n) +* Average case performance O(n^2) + +###### View the algorithm in [action][insertion-toptal] + + +### Merge +![alt text][merge-image] + +From [Wikipedia][merge-wiki]: In computer science, merge sort (also commonly spelled mergesort) is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945. + +__Properties__ +* Worst case performance O(n log n) +* Best case performance O(n) +* Average case performance O(n) + + +###### View the algorithm in [action][merge-toptal] + +### Quick +![alt text][quick-image] + +From [Wikipedia][quick-wiki]: Quicksort (sometimes called partition-exchange sort) is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order. + +__Properties__ +* Worst case performance O(n^2) +* Best case performance O(n log n) or O(n) with three-way partition +* Average case performance O(n^2) + +###### View the algorithm in [action][quick-toptal] + +### Selection +![alt text][selection-image] + +From [Wikipedia][selection-wiki]: The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right. + +__Properties__ +* Worst case performance O(n^2) +* Best case performance O(n^2) +* Average case performance O(n^2) + +###### View the algorithm in [action][selection-toptal] + +### Shell +![alt text][shell-image] + +From [Wikipedia][shell-wiki]: Shellsort is a generalization of insertion sort that allows the exchange of items that are far apart. The idea is to arrange the list of elements so that, starting anywherem considereing every nth element gives a sorted list. Such a list is said to be h-sorted. Equivanelty, it can be thought of as h intterleaved lists, each individually sorted. + +__Properties__ +* Worst case performance O(nlog2 2n) +* Best case performance O(n log n) +* Average case performance depends on gap sequence + +###### View the algorithm in [action][shell-toptal] + +###Time-Compexity Graphs + +Comparing the complexity of sorting algorithms (Bubble Sort, Insertion Sort, Selection Sort) + +[Complexity Graphs](https://github.com/prateekiiest/Python/blob/master/sorts/sortinggraphs.png) + +---------------------------------------------------------------------------------- + +## Search Algorithms + +### Linear +![alt text][linear-image] + +From [Wikipedia][linear-wiki]: linear search or sequential search is a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched. + Linear search runs in at worst linear time and makes at most n comparisons, where n is the length of the list. + +__Properties__ +* Worst case performance O(n) +* Best case performance O(1) +* Average case performance O(n) +* Worst case space complexity O(1) iterative + +### Binary +![alt text][binary-image] + +From [Wikipedia][binary-wiki]: Binary search, also known as half-interval search or logarithmic search, is a search algorithm that finds the position of a target value within a sorted array. It compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful. + +__Properties__ +* Worst case performance O(log n) +* Best case performance O(1) +* Average case performance O(log n) +* Worst case space complexity O(1) + +---------------------------------------------------------------------------------------------------------------------- + +## Ciphers + +### Caesar +![alt text][caesar]
+In cryptography, a **Caesar cipher**, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques.
+It is **a type of substitution cipher** in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on.
+The method is named after **Julius Caesar**, who used it in his private correspondence.
+The encryption step performed by a Caesar cipher is often incorporated as part of more complex schemes, such as the Vigenère cipher, and still has modern application in the ROT13 system. As with all single-alphabet substitution ciphers, the Caesar cipher is easily broken and in modern practice offers essentially no communication security. +###### Source: [Wikipedia](https://en.wikipedia.org/wiki/Caesar_cipher) + + + + + +[bubble-toptal]: https://www.toptal.com/developers/sorting-algorithms/bubble-sort +[bubble-wiki]: https://en.wikipedia.org/wiki/Bubble_sort +[bubble-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Bubblesort-edited-color.svg/220px-Bubblesort-edited-color.svg.png "Bubble Sort" + +[insertion-toptal]: https://www.toptal.com/developers/sorting-algorithms/insertion-sort +[insertion-wiki]: https://en.wikipedia.org/wiki/Insertion_sort +[insertion-image]: https://upload.wikimedia.org/wikipedia/commons/7/7e/Insertionsort-edited.png "Insertion Sort" + +[quick-toptal]: https://www.toptal.com/developers/sorting-algorithms/quick-sort +[quick-wiki]: https://en.wikipedia.org/wiki/Quicksort +[quick-image]: https://upload.wikimedia.org/wikipedia/commons/6/6a/Sorting_quicksort_anim.gif "Quick Sort" + +[merge-toptal]: https://www.toptal.com/developers/sorting-algorithms/merge-sort +[merge-wiki]: https://en.wikipedia.org/wiki/Merge_sort +[merge-image]: https://upload.wikimedia.org/wikipedia/commons/c/cc/Merge-sort-example-300px.gif "Merge Sort" + +[selection-toptal]: https://www.toptal.com/developers/sorting-algorithms/selection-sort +[selection-wiki]: https://en.wikipedia.org/wiki/Selection_sort +[selection-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Selection_sort_animation.gif/250px-Selection_sort_animation.gif "Selection Sort Sort" + +[shell-toptal]: https://www.toptal.com/developers/sorting-algorithms/shell-sort +[shell-wiki]: https://en.wikipedia.org/wiki/Shellsort +[shell-image]: https://upload.wikimedia.org/wikipedia/commons/d/d8/Sorting_shellsort_anim.gif "Shell Sort" + +[linear-wiki]: https://en.wikipedia.org/wiki/Linear_search +[linear-image]: http://www.tutorialspoint.com/data_structures_algorithms/images/linear_search.gif + +[binary-wiki]: https://en.wikipedia.org/wiki/Binary_search_algorithm +[binary-image]: https://upload.wikimedia.org/wikipedia/commons/f/f7/Binary_search_into_array.png + + +[caesar]: https://upload.wikimedia.org/wikipedia/commons/4/4a/Caesar_cipher_left_shift_of_3.svg From ca5366079693ba3f9d83226948ea05100408f252 Mon Sep 17 00:00:00 2001 From: smitbose Date: Sun, 25 Dec 2016 18:52:19 +0530 Subject: [PATCH 16/32] Created clean working tree --- Cryptography/RSA_Algorithm/rsa.py | 116 --------- Cryptography/RSA_Algortihm/rsa.py | 113 --------- Longest_Common_Subsequence/lcs.cpp | 73 ------ Longest_Increasing_Subsequence/a.out | Bin 13600 -> 0 bytes .../lis_n_log_n.cpp | 67 ----- .../lis_n_squared_sol.cpp | 73 ------ Minimum_Spanning_Tree/KruskalMST.cpp | 107 -------- Minimum_Spanning_Tree/Prims.cpp | 225 ----------------- Minimum_Spanning_Tree/a.out | Bin 53424 -> 0 bytes README.md | 170 ------------- Shortest_Path/Floyd-Warshall/a.out | Bin 13584 -> 0 bytes .../Floyd-Warshall/floyd_warshall.cpp | 57 ----- Shortest_Path/dijsktra/READMEDijkstra.md | 62 ----- Shortest_Path/dijsktra/a.out | Bin 33192 -> 0 bytes .../dijsktra/dijsktra_implementation.cpp | 230 ------------------ binaryIndexedTree/Reference.txt | 3 - binaryIndexedTree/SPOJ_ctrick.cpp | 116 --------- binaryIndexedTree/SPOJ_invcnt.cpp | 78 ------ binaryIndexedTree/binary_indexed_tree.cpp | 76 ------ .../SPOJ_horrible.cpp | 76 ------ editDistance/CODECHEF_seatsr.cpp | 78 ------ editDistance/SPOJ_edist.cpp | 42 ---- editDistance/a.out | Bin 13600 -> 0 bytes 23 files changed, 1762 deletions(-) delete mode 100644 Cryptography/RSA_Algorithm/rsa.py delete mode 100644 Cryptography/RSA_Algortihm/rsa.py delete mode 100644 Longest_Common_Subsequence/lcs.cpp delete mode 100755 Longest_Increasing_Subsequence/a.out delete mode 100644 Longest_Increasing_Subsequence/lis_n_log_n.cpp delete mode 100644 Longest_Increasing_Subsequence/lis_n_squared_sol.cpp delete mode 100644 Minimum_Spanning_Tree/KruskalMST.cpp delete mode 100644 Minimum_Spanning_Tree/Prims.cpp delete mode 100755 Minimum_Spanning_Tree/a.out delete mode 100644 README.md delete mode 100755 Shortest_Path/Floyd-Warshall/a.out delete mode 100644 Shortest_Path/Floyd-Warshall/floyd_warshall.cpp delete mode 100644 Shortest_Path/dijsktra/READMEDijkstra.md delete mode 100755 Shortest_Path/dijsktra/a.out delete mode 100644 Shortest_Path/dijsktra/dijsktra_implementation.cpp delete mode 100644 binaryIndexedTree/Reference.txt delete mode 100644 binaryIndexedTree/SPOJ_ctrick.cpp delete mode 100644 binaryIndexedTree/SPOJ_invcnt.cpp delete mode 100644 binaryIndexedTree/binary_indexed_tree.cpp delete mode 100644 binaryIndexedTree/range_query_range_update/SPOJ_horrible.cpp delete mode 100644 editDistance/CODECHEF_seatsr.cpp delete mode 100644 editDistance/SPOJ_edist.cpp delete mode 100755 editDistance/a.out diff --git a/Cryptography/RSA_Algorithm/rsa.py b/Cryptography/RSA_Algorithm/rsa.py deleted file mode 100644 index d4d764752..000000000 --- a/Cryptography/RSA_Algorithm/rsa.py +++ /dev/null @@ -1,116 +0,0 @@ -import random - - -''' -Euclid's algorithm for determining the greatest common divisor -Use iteration to make it faster for larger integers -''' -def gcd(a, b): - while b != 0: - a, b = b, a % b - return a - -''' -Euclid's extended algorithm for finding the multiplicative inverse of two numbers -''' -def multiplicative_inverse(e, phi): - d = 0 - x1 = 0 - x2 = 1 - y1 = 1 - temp_phi = phi - - while e > 0: - temp1 = temp_phi/e - temp2 = temp_phi - temp1 * e - temp_phi = e - e = temp2 - - x = x2- temp1* x1 - y = d - temp1 * y1 - - x2 = x1 - x1 = x - d = y1 - y1 = y - - if temp_phi == 1: - return d + phi - -''' -Tests to see if a number is prime. -''' -def is_prime(num): - if num == 2: - return True - if num < 2 or num % 2 == 0: - return False - for n in xrange(3, int(num**0.5)+2, 2): - if num % n == 0: - return False - return True - -def generate_keypair(p, q): - if not (is_prime(p) and is_prime(q)): - raise ValueError('Both numbers must be prime.') - elif p == q: - raise ValueError('p and q cannot be equal') - #n = pq - n = p * q - - #Phi is the totient of n - # n number theory, Euler's totient function counts the positive integers up to a given integer n that are relatively prime to n. - phi = (p-1) * (q-1) - - #Choose an integer e such that e and phi(n) are coprime - e = random.randrange(1, phi) - - #Use Euclid's Algorithm to verify that e and phi(n) are comprime - - g = gcd(e, phi) - while g != 1: - e = random.randrange(1, phi) - g = gcd(e, phi) - - #Use Extended Euclid's Algorithm to generate the private key - - d = multiplicative_inverse(e, phi) - - #Return public and private keypair - #Public key is (e, n) and private key is (d, n) - return ((e, n), (d, n)) - -def encrypt(pk, plaintext): - #Unpack the key into it's components - key, n = pk - #Convert each letter in the plaintext to numbers based on the character using a^b mod m - cipher = [(ord(char) ** key) % n for char in plaintext] - #Return the array of bytes - return cipher - -def decrypt(pk, ciphertext): - #Unpack the key into its components - key, n = pk - #Generate the plaintext based on the ciphertext and key using a^b mod m - plain = [chr((char ** key) % n) for char in ciphertext] - #Return the array of bytes as a string - return ''.join(plain) - - -if __name__ == '__main__': - ''' - Detect if the script is being run directly by the user - ''' - print "RSA Encrypter/ Decrypter" - p = int(raw_input("Enter a prime number (17, 19, 23, etc): ")) - q = int(raw_input("Enter another prime number (Not one you entered above): ")) - print "Generating your public/private keypairs now . . ." - public, private = generate_keypair(p, q) - print "Your public key is ", public ," and your private key is ", private - message = raw_input("Enter a message to encrypt with your private key: ") - encrypted_msg = encrypt(private, message) - print "Your encrypted message is: " - print ''.join(map(lambda x: str(x), encrypted_msg)) - print "Decrypting message with public key ", public ," . . ." - print "Your message is:" - print decrypt(public, encrypted_msg) diff --git a/Cryptography/RSA_Algortihm/rsa.py b/Cryptography/RSA_Algortihm/rsa.py deleted file mode 100644 index 3199e6bfc..000000000 --- a/Cryptography/RSA_Algortihm/rsa.py +++ /dev/null @@ -1,113 +0,0 @@ -import random - - -''' -Euclid's algorithm for determining the greatest common divisor -Use iteration to make it faster for larger integers -''' -def gcd(a, b): - while b != 0: - a, b = b, a % b - return a - -''' -Euclid's extended algorithm for finding the multiplicative inverse of two numbers -''' -def multiplicative_inverse(e, phi): - d = 0 - x1 = 0 - x2 = 1 - y1 = 1 - temp_phi = phi - - while e > 0: - temp1 = temp_phi/e - temp2 = temp_phi - temp1 * e - temp_phi = e - e = temp2 - - x = x2- temp1* x1 - y = d - temp1 * y1 - - x2 = x1 - x1 = x - d = y1 - y1 = y - - if temp_phi == 1: - return d + phi - -''' -Tests to see if a number is prime. -''' -def is_prime(num): - if num == 2: - return True - if num < 2 or num % 2 == 0: - return False - for n in xrange(3, int(num**0.5)+2, 2): - if num % n == 0: - return False - return True - -def generate_keypair(p, q): - if not (is_prime(p) and is_prime(q)): - raise ValueError('Both numbers must be prime.') - elif p == q: - raise ValueError('p and q cannot be equal') - #n = pq - n = p * q - - #Phi is the totient of n - phi = (p-1) * (q-1) - - #Choose an integer e such that e and phi(n) are coprime - e = random.randrange(1, phi) - - #Use Euclid's Algorithm to verify that e and phi(n) are comprime - g = gcd(e, phi) - while g != 1: - e = random.randrange(1, phi) - g = gcd(e, phi) - - #Use Extended Euclid's Algorithm to generate the private key - d = multiplicative_inverse(e, phi) - - #Return public and private keypair - #Public key is (e, n) and private key is (d, n) - return ((e, n), (d, n)) - -def encrypt(pk, plaintext): - #Unpack the key into it's components - key, n = pk - #Convert each letter in the plaintext to numbers based on the character using a^b mod m - cipher = [(ord(char) ** key) % n for char in plaintext] - #Return the array of bytes - return cipher - -def decrypt(pk, ciphertext): - #Unpack the key into its components - key, n = pk - #Generate the plaintext based on the ciphertext and key using a^b mod m - plain = [chr((char ** key) % n) for char in ciphertext] - #Return the array of bytes as a string - return ''.join(plain) - - -if __name__ == '__main__': - ''' - Detect if the script is being run directly by the user - ''' - print "RSA Encrypter/ Decrypter" - p = int(raw_input("Enter a prime number (17, 19, 23, etc): ")) - q = int(raw_input("Enter another prime number (Not one you entered above): ")) - print "Generating your public/private keypairs now . . ." - public, private = generate_keypair(p, q) - print "Your public key is ", public ," and your private key is ", private - message = raw_input("Enter a message to encrypt with your private key: ") - encrypted_msg = encrypt(private, message) - print "Your encrypted message is: " - print ''.join(map(lambda x: str(x), encrypted_msg)) - print "Decrypting message with public key ", public ," . . ." - print "Your message is:" - print decrypt(public, encrypted_msg) diff --git a/Longest_Common_Subsequence/lcs.cpp b/Longest_Common_Subsequence/lcs.cpp deleted file mode 100644 index e931be526..000000000 --- a/Longest_Common_Subsequence/lcs.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -#include -using namespace std; -#define lli long long int -#define infinite 0xffff -#define Min(a,b) (((a)<(b))?(a):(b)) -#define Max(a,b) (((a)>(b))?(a):(b)) -#define fr(i,j,s) for(i = j ; i < s ; i++) -#define ifr(i,j,s) for(i = j ; i >= s , i--) -void lcs(char * a, char *b) -{ - lli lena,lenb,i,j,count; - lena=strlen(a); - lenb=strlen(b); - char record[lena+1][lenb+1]; - //Code to generate the map - fr(i,0,lena+1) - { - fr(j,0,lenb+1) - { - if(i==0 || j==0) - { - record[i][j]=0; - } - else if(a[i-1]==b[j-1]) - { - record[i][j]=record[i-1][j-1]+1; - } - else - { - record[i][j] = Max(record[i-1][j],record[i][j-1]); - } - } - } - //Code to find the subsequence - i = lena; - j = lenb; - char sub[record[lena][lenb]]; - lli index = record[i][j]-1; - while( i > 0 && j > 0 ) - { - if(a[i-1]==b[j-1]) - { - sub[index]=a[i-1]; - i--; - j--; - index--; - } - else if(Max(record[i-1][j],record[i][j-1]) == record[i-1][j]) - { - i--; - } - else - { - j--; - } - } - fr(i,0,record[lena][lenb]) - { - cout<>str1; - cin>>str2; - lcs(str1,str2); - return 0; -} \ No newline at end of file diff --git a/Longest_Increasing_Subsequence/a.out b/Longest_Increasing_Subsequence/a.out deleted file mode 100755 index 4f7b1a9728c0681ce1f6577a88fd744877929a8b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13600 zcmeHOeQ;Y>mA{f4+f7|rDJeM3woyY1NsCp>ae~wAwvrtsPsK@$KT0Xe@ z=_xqf4Y(`XMYt{*K01LJhQJI=fj=<+Fex92l0f4!omscDuwm)$c$n?3+!RPZ=(^pu z-ru?J9{K56>ULmuX8-W@Je_-f_ndR@J@0WSI)#l>q5cTbFK-Ea^Ipb+5HCxWs}&CUU1ar zjkstGPLJj;1@C{;RrTW?A);`wsRSor!c-ABkk+9pO~M*y|4+6*};AG8^jM*Vmu!*FzFWWU`^Y zNo4ztj(94T3`hG7zdt$_$>>HVk}$I2XeiVNYzK@bqIx=OWa5$W@PIzhric1>q2a5m z>o%+FH+Do5DQP>I4Zl0P(E(W9srP;)YPKnw&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TIW>J?14&dL=Wrw zeTb+^q#~JPdQUoiWN@N)5(#bE*B3kx(nAOLQcRe1m&z;sL;LpihY)=g?CJ@TL`Az} zm4J*b6Z+nd9}FG{cMEz%GDD(dXDB!;5Rh?EDgsJHO+~Xg={Zpr-T`Nzfw2C+$E?Xm zyc$7aRjV^2;3!B-6(dTEVzaCPUAB_dA!iifX0!fI!E*?A`x8Ra>=hh>gJOx4p3BDJ zd8&_xZ)K>SZuPv5GQPhQbw?3yHp6->o7TrLiYU&{jAWyGqQ+f~frCe1zF$Nwp>ZqD z>sSe;vsH=Mzj7G|2--y8bTeAej{m8lgEl*H`3NtA^~|oy<>k-*p>sF3u<}02&-)yA z&F5~eh-9tl{b1;+^YJUI8anhv|I+Wm&%kc}n--!WL21=W~mUcmvMw z8<3UB?!Wti(pjJD=kv{a^#Wt7(p#q}%P~CyoZcNU&*z{vrQfUch$R_rzk8#mCb`xAp{L5_qdVKR?c@hJKSBZ_`t(_^M5x&wT@KQ-a^~u)Mwf zr<6YXpP$=?l|K8Wmj2^5eLhF>{|5}PqN4Wte`wR^^JY=i|A=kC^8I78MPx{n<^Uyr z?&tp(U_YCsEBBxIr;%yK#rk}nXjK1CVXx25UxF?*k@fkU=y{j={|a65G3)brxJBtN zsQ&YP;QF~=|6!}2&&^9)P=LhpCbz;fei;SU_LtAsUQ=U&6%}PYrmq6G>hn2#!fPsU zJC*vX_Pl`tvc>)9=h-Q*sloez$qAugW(6JCss6SyVrE#s&xVsMC8isY=elKq`gzuC vW_bPJGS;*5Ja-r)x^R=pO{sO@2C&pd_8YH1G(W4=KfK-4zr!|R?DhW-a8kfV diff --git a/Longest_Increasing_Subsequence/lis_n_log_n.cpp b/Longest_Increasing_Subsequence/lis_n_log_n.cpp deleted file mode 100644 index 931ddcb1a..000000000 --- a/Longest_Increasing_Subsequence/lis_n_log_n.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include -using namespace std; -#define lli long long int -#define infinite 0xffff -#define Min(a,b) (((a)<(b))?(a):(b)) -#define Max(a,b) (((a)>(b))?(a):(b)) -#define fr(i,j,s) for(i = j ; i < s ; i++) -#define ifr(i,j,s) for(i = j ; i >= s ; i--) -lli binary_LookUp(lli * record ,lli a , lli len , lli val) -{ - while(len-a > 1) - { - lli m = a + (len-a)/2; - if(record[m]>=val) - { - len = m ; - } - else - { - a = m ; - } - } - return len ; -} -void lis(lli * a, lli n) -{ - lli i,j,count,index; - lli record[n]; - //Code to generate the map - record[0]=a[0]; - lli len = 1 ; - fr(i,1,n) - { - if(a[i] record[len-1]) - { - record[len] = a[i]; - len++; - } - else - { - index=binary_LookUp(record,-1,len-1,a[i]); - record[index] = a[i]; - } - } - cout<>n; - lli a[n]; - fr(i,0,n) - { - cin>>a[i]; - } - lis(a,n); - return 0; -} \ No newline at end of file diff --git a/Longest_Increasing_Subsequence/lis_n_squared_sol.cpp b/Longest_Increasing_Subsequence/lis_n_squared_sol.cpp deleted file mode 100644 index 471a6aa33..000000000 --- a/Longest_Increasing_Subsequence/lis_n_squared_sol.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -using namespace std; -#define lli long long int -#define infinite 0xffff -#define Min(a,b) (((a)<(b))?(a):(b)) -#define Max(a,b) (((a)>(b))?(a):(b)) -#define fr(i,j,s) for(i = j ; i < s ; i++) -#define ifr(i,j,s) for(i = j ; i >= s ; i--) -void lis(lli * a, lli n) -{ - lli i,j,count; - lli record[n]; - //Code to generate the map - fr(i,0,n) - { - record[i] = 0 ; - } - fr(i,0,n) - { - fr(j,0,i) - { - if( (a[i]>a[j]) && (record[i]<(record[j]+1)) ) - { - record[i]=record[j]+1; - } - } - } - lli max = 0; - lli index = 0 ; - fr(i,0,n) - { - //cout<>n; - lli a[n]; - fr(i,0,n) - { - cin>>a[i]; - } - lis(a,n); - return 0; -} \ No newline at end of file diff --git a/Minimum_Spanning_Tree/KruskalMST.cpp b/Minimum_Spanning_Tree/KruskalMST.cpp deleted file mode 100644 index 222e852dd..000000000 --- a/Minimum_Spanning_Tree/KruskalMST.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include -using namespace std; -#define lli long long int -#define infinite numeric_limits::max() -#define Min(a,b) ((a)<(b)?(a):(b)) -#define Max(a,b) ((a)>(b)?(a):(b)) -#define fr(i,j,s) for(i = j ; i < s ; i++) -#define ifr(i,j,s) for(i = j ; i >= s , i--) -struct edge -{ - lli wt; - int src; - int dest; -}; -struct Graph -{ - int V; - int E; - struct edge* array; -}; -struct sub -{ - int parent; - int rank; -}; -bool comp(struct edge &a, struct edge &b) -{ - return ((a.wt)<(b.wt)); -} -int find(struct sub subset[], int i) -{ - if(subset[i].parent != i) - { - subset[i].parent = find(subset,subset[i].parent); - } - return subset[i].parent ; -} -void Union(struct sub subset[] , int x, int y) -{ - int xfather = find(subset,x); - int yfather = find(subset,y); - if(subset[xfather].rankV = V ; - G->E = E ; - G->array = (struct edge*)malloc(E*sizeof(struct edge)); - return G ; -} -void KruskalMST(struct Graph *G) -{ - int i ; - int V = G->V ; - int E = G->E ; - lli sum = 0 ; - struct sub subset[G->V]; - fr(i,0,V) - { - subset[i].parent = i ; - subset[i].rank = 0 ; - } - sort(G->array, (G->array)+G->E,comp); - fr(i,0,E) - { - int x = find(subset,G->array[i].src); - int y = find(subset,G->array[i].dest); - if(x==y) - continue; - else - { - Union(subset,G->array[i].src,G->array[i].dest); - sum+=G->array[i].wt; - } - } - cout<>v>>e; - struct Graph* G = createGraph(v,e); - int ed = 0; - int temp = e ; - while(e--) - { - cin>>a>>b>>wt; - G->array[ed].src=a-1; - G->array[ed].dest=b-1; - G->array[ed].wt=wt; - ed++; - } - cin>>a; - KruskalMST(G); - return 0; -} \ No newline at end of file diff --git a/Minimum_Spanning_Tree/Prims.cpp b/Minimum_Spanning_Tree/Prims.cpp deleted file mode 100644 index 242040193..000000000 --- a/Minimum_Spanning_Tree/Prims.cpp +++ /dev/null @@ -1,225 +0,0 @@ -#include -using namespace std; -#define lli long long int -#define infinite numeric_limits::max() -#define Min(a,b) ((a)<(b)?(a):(b)) -#define Max(a,b) ((a)>(b)?(a):(b)) -#define fr(i,j,s) for(i = j ; i < s ; i++) -#define ifr(i,j,s) for(i = j ; i >= s , i--) -struct adjListNode -{ - int dest; - int wt; - struct adjListNode *next; -}; -struct adjList -{ - struct adjListNode *head; -}; -struct Graph -{ - int V ; - struct adjList *array; -}; -struct adjListNode * newAdjNode(int dest, int wt) -{ - struct adjListNode *newNode = (struct adjListNode* )malloc(sizeof(struct adjListNode)); - newNode->dest = dest; - newNode->wt = wt; - newNode->next = NULL ; - return newNode; -} -struct Graph* createGraph(int V,int E) -{ - int i ; - struct Graph* G = (struct Graph *)malloc(sizeof(struct Graph)); - G->V = V ; - G->array = (struct adjList*)malloc(E*sizeof(struct adjList)); - fr(i,0,V) - { - G->array[i].head = NULL ; - } - return G ; -} -void addEdge(struct Graph *G,int src, int dest, int wt) -{ - struct adjListNode*temp=newAdjNode(dest,wt); - temp->next=G->array[src].head; - G->array[src].head=temp; - - temp=newAdjNode(src,wt); - temp->next=G->array[dest].head; - G->array[dest].head=temp; -} -struct MinHeapNode -{ - int v; - lli dist; -}; -struct MinHeap -{ - int size; - int capacity; - int *pos; - struct MinHeapNode **array; -}; -struct MinHeapNode* newMinHeapNode(int v, lli dist) -{ - struct MinHeapNode* minHeapNode = - (struct MinHeapNode*) malloc(sizeof(struct MinHeapNode)); - minHeapNode->v = v; - minHeapNode->dist = dist; - return minHeapNode; -} -struct MinHeap* createMinHeap(int capacity) -{ - struct MinHeap* minHeap = - (struct MinHeap*) malloc(sizeof(struct MinHeap)); - minHeap->pos = (int *)malloc(capacity * sizeof(int)); - minHeap->size = 0; - minHeap->capacity = capacity; - minHeap->array = - (struct MinHeapNode**) malloc(capacity * sizeof(struct MinHeapNode*)); - return minHeap; -} -void swapMinHeapNode(struct MinHeapNode** a, struct MinHeapNode** b) -{ - struct MinHeapNode* t = *a; - *a = *b; - *b = t; -} -void minHeapify(struct MinHeap* minHeap, int idx) -{ - int smallest, left, right; - smallest = idx; - left = 2 * idx + 1; - right = 2 * idx + 2; - - if (left < minHeap->size && - minHeap->array[left]->dist < minHeap->array[smallest]->dist ) - smallest = left; - - if (right < minHeap->size && - minHeap->array[right]->dist < minHeap->array[smallest]->dist ) - smallest = right; - - if (smallest != idx) - { - MinHeapNode *smallestNode = minHeap->array[smallest]; - MinHeapNode *idxNode = minHeap->array[idx]; - - minHeap->pos[smallestNode->v] = idx; - minHeap->pos[idxNode->v] = smallest; - - swapMinHeapNode(&minHeap->array[smallest], &minHeap->array[idx]); - - minHeapify(minHeap, smallest); - } -} - -int isEmpty(struct MinHeap* minHeap) -{ - return minHeap->size == 0; -} - -struct MinHeapNode* extractMin(struct MinHeap* minHeap) -{ - if (isEmpty(minHeap)) - return NULL; - - struct MinHeapNode* root = minHeap->array[0]; - - struct MinHeapNode* lastNode = minHeap->array[minHeap->size - 1]; - minHeap->array[0] = lastNode; - - minHeap->pos[root->v] = minHeap->size-1; - minHeap->pos[lastNode->v] = 0; - - --minHeap->size; - minHeapify(minHeap, 0); - - return root; -} - -void decreaseKey(struct MinHeap* minHeap, int v, lli dist) -{ - int i = minHeap->pos[v]; - - minHeap->array[i]->dist = dist; - - while (i && minHeap->array[i]->dist < minHeap->array[(i - 1) / 2]->dist) - { - minHeap->pos[minHeap->array[i]->v] = (i-1)/2; - minHeap->pos[minHeap->array[(i-1)/2]->v] = i; - swapMinHeapNode(&minHeap->array[i], &minHeap->array[(i - 1) / 2]); - i = (i - 1) / 2; - } -} - -bool isInMinHeap(struct MinHeap *minHeap, int v) -{ - if (minHeap->pos[v] < minHeap->size) - return true; - return false; -} -void PrimMST(struct Graph*G,int src) -{ - lli i,j; - int V = G->V; - lli dist[V],parent[V],sto[V]; - struct MinHeap * minHeap = createMinHeap(V); - fr(i,0,V) - { - if(i==src) - continue; - parent[i] = -1 ; - sto[i] = -1 ; - dist[i] = infinite ; - minHeap->array[i] = newMinHeapNode(i,dist[i]); - minHeap->pos[i] = i ; - } - dist[src] = 0 ; - minHeap->array[src] = newMinHeapNode(src,dist[src]) ; - minHeap->pos[src] = src ; - minHeap->size = V ; - lli sum=0; - while(!isEmpty(minHeap)) - { - struct MinHeapNode* minHeapNode = extractMin(minHeap); - int u = minHeapNode->v; - struct adjListNode* pCrawl = G->array[u].head; - while (pCrawl != NULL) - { - int v = pCrawl->dest; - if (isInMinHeap(minHeap, v) && (pCrawl->wt < dist[v])) - { - parent[v] = u ; - if(dist[v] != infinite) - sum -= (dist[v]-pCrawl->wt) ; - else - sum+=pCrawl->wt; - dist[v] =pCrawl->wt; - decreaseKey(minHeap, v, dist[v]); - } - pCrawl = pCrawl->next; - } - } - fr(i,0,V) - cout<>v>>e; - struct Graph* G = createGraph(v,e); - while(e--) - { - cin>>a>>b>>wt; - addEdge(G,a-1,b-1,wt); - } - cin>>a; - PrimMST(G,0); - return 0; -} \ No newline at end of file diff --git a/Minimum_Spanning_Tree/a.out b/Minimum_Spanning_Tree/a.out deleted file mode 100755 index b763fff5e3ca753728b7e0081d687a7f9370d3f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53424 zcmeIbd0>>))j$3`Gg*cJA%qYDVhkVhlf^;5Lk=l zI|@y)6|aZu7!IGI5`@q2NWj3`b$JGwd|yC5%K1s3ES+$rF0VhmxU~ER>f){GjiH)Z zrPCYhrZt9|JGM^SS~hFitWtM-i@QYXP5w-~bVaq4Wb{~o7-i1Ehc-a^is{qO`_4_@ zUU$jHRo`?y>^beBCvToh+7NumL)9w_W||{7@*av$`yJ_yG5>sTK%w_n%ZBeBv$Qlm0*Y z!T$sJq1H(2?xOVwp?`ocpZoElezLUxAdXK6AL8$JdGH;5Qjm{)_7$%eWR~V*!M@tV zb+uEb(57Ztet$z#OS8W{9B2#s{g(gS&Hk0ahERJr*tV!K(B2+wxBTT*%l&o1HjS=Y zzNoRKIan2_X$&e_a?08jmEp2bOS``&&>k!;Zw`eQ7kf8be&Aag+r1S_R#vuD`n`e( zwY7U!hN8i(2v&wmgUxk~<+YX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#ls-V5Ij1{0jWO=6#y^Sqp9L9Pl9Bx8{M+SL`4ZD7 z#*ZKw$5keyh9;kZ?*Sj1-<;!LrSls(4I7is#Q%-}ai;#}ynm<8Z^i+W zzQ6=D>;+``I(dX@@~@0wRDfyu80bR4gcU`7|6Vh^${405CZ-+HPyU)2D#Nq$V!8G$ zYg|A1-J4XtR@3nPlwaIW{yX)C{(%IAC(1uh=TFpM%~h(vRpuZhp?t%~*H8IBzE5Si z`(yMs6v<56>mmfK`L2qobNML6lxr}ICln#1hrXv$_~`WUjKgOZK1LnJ|I - -[![Join the chat at https://gitter.im/codeIIEST/Algorithms](https://badges.gitter.im/codeIIEST/Algorithms.svg)](https://gitter.im/codeIIEST/Algorithms?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - - - - -## Sort Algorithms - - -### Bubble -![alt text][bubble-image] - -From [Wikipedia][bubble-wiki]: Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. - -__Properties__ -* Worst case performance O(n^2) -* Best case performance O(n) -* Average case performance O(n^2) - -###### View the algorithm in [action][bubble-toptal] - - - -### Insertion -![alt text][insertion-image] - -From [Wikipedia][insertion-wiki]: Insertion sort is a simple sorting algorithm that builds the final sorted array (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as quicksort, heapsort, or merge sort. - -__Properties__ -* Worst case performance O(n^2) -* Best case performance O(n) -* Average case performance O(n^2) - -###### View the algorithm in [action][insertion-toptal] - - -### Merge -![alt text][merge-image] - -From [Wikipedia][merge-wiki]: In computer science, merge sort (also commonly spelled mergesort) is an efficient, general-purpose, comparison-based sorting algorithm. Most implementations produce a stable sort, which means that the implementation preserves the input order of equal elements in the sorted output. Mergesort is a divide and conquer algorithm that was invented by John von Neumann in 1945. - -__Properties__ -* Worst case performance O(n log n) -* Best case performance O(n) -* Average case performance O(n) - - -###### View the algorithm in [action][merge-toptal] - -### Quick -![alt text][quick-image] - -From [Wikipedia][quick-wiki]: Quicksort (sometimes called partition-exchange sort) is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order. - -__Properties__ -* Worst case performance O(n^2) -* Best case performance O(n log n) or O(n) with three-way partition -* Average case performance O(n^2) - -###### View the algorithm in [action][quick-toptal] - -### Selection -![alt text][selection-image] - -From [Wikipedia][selection-wiki]: The algorithm divides the input list into two parts: the sublist of items already sorted, which is built up from left to right at the front (left) of the list, and the sublist of items remaining to be sorted that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist is the entire input list. The algorithm proceeds by finding the smallest (or largest, depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with the leftmost unsorted element (putting it in sorted order), and moving the sublist boundaries one element to the right. - -__Properties__ -* Worst case performance O(n^2) -* Best case performance O(n^2) -* Average case performance O(n^2) - -###### View the algorithm in [action][selection-toptal] - -### Shell -![alt text][shell-image] - -From [Wikipedia][shell-wiki]: Shellsort is a generalization of insertion sort that allows the exchange of items that are far apart. The idea is to arrange the list of elements so that, starting anywherem considereing every nth element gives a sorted list. Such a list is said to be h-sorted. Equivanelty, it can be thought of as h intterleaved lists, each individually sorted. - -__Properties__ -* Worst case performance O(nlog2 2n) -* Best case performance O(n log n) -* Average case performance depends on gap sequence - -###### View the algorithm in [action][shell-toptal] - -###Time-Compexity Graphs - -Comparing the complexity of sorting algorithms (Bubble Sort, Insertion Sort, Selection Sort) - -[Complexity Graphs](https://github.com/prateekiiest/Python/blob/master/sorts/sortinggraphs.png) - ----------------------------------------------------------------------------------- - -## Search Algorithms - -### Linear -![alt text][linear-image] - -From [Wikipedia][linear-wiki]: linear search or sequential search is a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched. - Linear search runs in at worst linear time and makes at most n comparisons, where n is the length of the list. - -__Properties__ -* Worst case performance O(n) -* Best case performance O(1) -* Average case performance O(n) -* Worst case space complexity O(1) iterative - -### Binary -![alt text][binary-image] - -From [Wikipedia][binary-wiki]: Binary search, also known as half-interval search or logarithmic search, is a search algorithm that finds the position of a target value within a sorted array. It compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful. - -__Properties__ -* Worst case performance O(log n) -* Best case performance O(1) -* Average case performance O(log n) -* Worst case space complexity O(1) - ----------------------------------------------------------------------------------------------------------------------- - -## Ciphers - -### Caesar -![alt text][caesar]
-In cryptography, a **Caesar cipher**, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques.
-It is **a type of substitution cipher** in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on.
-The method is named after **Julius Caesar**, who used it in his private correspondence.
-The encryption step performed by a Caesar cipher is often incorporated as part of more complex schemes, such as the Vigenère cipher, and still has modern application in the ROT13 system. As with all single-alphabet substitution ciphers, the Caesar cipher is easily broken and in modern practice offers essentially no communication security. -###### Source: [Wikipedia](https://en.wikipedia.org/wiki/Caesar_cipher) - - - - - -[bubble-toptal]: https://www.toptal.com/developers/sorting-algorithms/bubble-sort -[bubble-wiki]: https://en.wikipedia.org/wiki/Bubble_sort -[bubble-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Bubblesort-edited-color.svg/220px-Bubblesort-edited-color.svg.png "Bubble Sort" - -[insertion-toptal]: https://www.toptal.com/developers/sorting-algorithms/insertion-sort -[insertion-wiki]: https://en.wikipedia.org/wiki/Insertion_sort -[insertion-image]: https://upload.wikimedia.org/wikipedia/commons/7/7e/Insertionsort-edited.png "Insertion Sort" - -[quick-toptal]: https://www.toptal.com/developers/sorting-algorithms/quick-sort -[quick-wiki]: https://en.wikipedia.org/wiki/Quicksort -[quick-image]: https://upload.wikimedia.org/wikipedia/commons/6/6a/Sorting_quicksort_anim.gif "Quick Sort" - -[merge-toptal]: https://www.toptal.com/developers/sorting-algorithms/merge-sort -[merge-wiki]: https://en.wikipedia.org/wiki/Merge_sort -[merge-image]: https://upload.wikimedia.org/wikipedia/commons/c/cc/Merge-sort-example-300px.gif "Merge Sort" - -[selection-toptal]: https://www.toptal.com/developers/sorting-algorithms/selection-sort -[selection-wiki]: https://en.wikipedia.org/wiki/Selection_sort -[selection-image]: https://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Selection_sort_animation.gif/250px-Selection_sort_animation.gif "Selection Sort Sort" - -[shell-toptal]: https://www.toptal.com/developers/sorting-algorithms/shell-sort -[shell-wiki]: https://en.wikipedia.org/wiki/Shellsort -[shell-image]: https://upload.wikimedia.org/wikipedia/commons/d/d8/Sorting_shellsort_anim.gif "Shell Sort" - -[linear-wiki]: https://en.wikipedia.org/wiki/Linear_search -[linear-image]: http://www.tutorialspoint.com/data_structures_algorithms/images/linear_search.gif - -[binary-wiki]: https://en.wikipedia.org/wiki/Binary_search_algorithm -[binary-image]: https://upload.wikimedia.org/wikipedia/commons/f/f7/Binary_search_into_array.png - - -[caesar]: https://upload.wikimedia.org/wikipedia/commons/4/4a/Caesar_cipher_left_shift_of_3.svg diff --git a/Shortest_Path/Floyd-Warshall/a.out b/Shortest_Path/Floyd-Warshall/a.out deleted file mode 100755 index 162a7202c3524a91bb5bbb22b6a15d741f901308..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13584 zcmeHOe{5UVb-pBJTZtV?a_vNp8=Fy`)=n!{lx0m$u!NLE`6-ZXRg#k|jq^m2l*NV; z1@h66gJzW>D+{5jbF*ep(*!fNVF-qz&4#pa(;}8^FLJQ}Q#+&$wyZGPBp?%aa9c0a zQYYMZ?z@M4d?F1m!~Pj`g~xNxch5QZ-t*r5_1@7}f<0YMheL33ihBfclhu9+nZH7u zY?Q3R+QbdQFSd!TVl9w0xcst&sF`EBtV}blR&p-TDqL+&6KHe#Wrpb|O;|AH780fU zipj6CCf!kIvP^~WNPzUHt;@Gb7IaW%m_DW2F;9(>$s>OWCcXM?k_8=<8KxIi!mes=3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pp b/Shortest_Path/Floyd-Warshall/floyd_warshall.cpp deleted file mode 100644 index 24e6cb3a2..000000000 --- a/Shortest_Path/Floyd-Warshall/floyd_warshall.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -using namespace std; -#define lli long long int -#define infinite numeric_limits::max() -#define Min(a,b) ((a)<(b)?(a):(b)) -#define Max(a,b) ((a)>(b)?(a):(b)) -#define fr(i,j,s) for(i = j ; i < s ; i++) -#define ifr(i,j,s) for(i = j ; i >= s , i--) -void floydWasrshall(lli G[][400],int V) -{ - int u , v , w; - fr(u,0,V) - { - fr(v,0,V) - { - fr(w,0,V) - { - if(G[v][u]+G[u][w] < G[v][w]) - G[v][w] = G[v][u]+G[u][w] ; - } - } - } -} -int main(void) -{ - int test,v,e,a,b,i,j; - lli wt; - cin>>v>>e; - int ed = 0; - lli graph[400][400]; - int temp = e ; - fr(i,0,v) - { - fr(j,0,v) - { - graph[i][j] = infinite ; - if(i==j) - graph[i][j] = 0; - } - } - while(e--) - { - cin>>a>>b>>wt; - graph[a-1][b-1] = wt; - } - lli q ; - cin>>q; - floydWasrshall(graph,v); - while(q--) - { - cin>>a>>b; - if(graph[a-1][b-1] == infinite ) - graph[a-1][b-1] = -1 ; - cout<hFD? z@AG{B=+T_D_u6Z%z4qE`uf5OShcnx~OBdM;Ls^$i%~O&aSRp8VSE{?iqEMFaWx-RXXbU<_F?PT-{LQjy#4KBdBrG^eqm>0M4GCFa;;Jx{8pej} ztOXTx}o%8WWA7FX@ zsJ8v>4*Qnal|E5>?Cz>alw~>iv-(XbC)_k&aD#!T{OC;sY-9iR(ZGq`-!2_` z%b*27^?Q{=(2zb#DaX|ZeoR03*MaX#PIEu@?*l_)#=g z7d-oH`c9eh`x}~DBK~MB&=&LimA`tke?_Pv9F2wA7BmH-(NI+Rt5z=a*M-_l^vY!m znpz^Em4S^-AzjvY$py=6W3$37QUAt3G&H>`5{@k_^=?*v;9Hua-kL=#YFldkUO|N0 zqTUr@Bx_^SLy@|ss$gx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ZZa?Xv9q$r???K3ba)>p=6*jIEMJ3eIHPWlrPS8nj@FlYi6CVQ6|eRLaX8y9KFY0t zz7IjT&)9SK+V976Tf*&9pPu25Nxu`B=v-`s!I|_AV5T-J<#0f@^Gx@*em*mmrT^W} z|Lsp}_Nt+ey^)YSxawU6j_n>(!T&15CjaUSmLr#iKa1abem-I%4wwzb8**YNi@(5>vKkOekvPBgoV~+T)cS6>NiH(1 zG~q?~<2SRd`mN{jiL4Np)qYEVi_U_ZK*MivTY2lby~gCP5h?ikDj;br{Y|vG6bY(o z@$b*5kfQx2zfW>_pWcKPzt#R-z>|NzS>A2(cboh!(|+XVGhizJwZM_YB#-YGI84IS zCtKE)e03s|%x~>0l$iWSl8KRant2P}n8I&8U*Lzp<@z<1PP!~U3w0|J$@N?N6t9^7 zhQbtMk&CV386@`OkNlSXt^JInCckADkjRzV{=0!q=C}4etl!zb$KDnI}AR5HJ{ zKXS`3&GDwCm?^;OKTF<0B=9!9i~-`T=fzXzRzj-1Qu$v35B{Z4oZos5b(mWYsr0G& z*TGBuIR<%I`!dci$^RC3Xk&}t+P^6<`HxaKE~_7``mJ`oi?ZbUt$m(T=GKTsFG6s$ z@)kUi!XMuca%qkZ4dQo;&w?MJB)NX;`MblVSu8y*0T!Q?{}c)0toHABZIGg?T>|32 zW3O{cnP@AkxY5JE4rr)aiQ$ESThuu0jv<&8ThmO$BO?fwtPo(==+|ihHL(f G{r(S(;oz(Q diff --git a/Shortest_Path/dijsktra/dijsktra_implementation.cpp b/Shortest_Path/dijsktra/dijsktra_implementation.cpp deleted file mode 100644 index d2d0025f5..000000000 --- a/Shortest_Path/dijsktra/dijsktra_implementation.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include -using namespace std; -#define lli long long int -#define infinite 0xffff -#define Min(a,b) ((a)<(b)?(a):(b)) -#define Max(a,b) ((a)>(b)?(a):(b)) -#define fr(i,j,s) for(i = j ; i < s ; i++) -#define ifr(i,j,s) for(i = j ; i >= s , i--) -struct adjListNode -{ - int dest; - int wt; - struct adjListNode *next; -}; -struct adjList -{ - struct adjListNode *head; -}; -struct Graph -{ - int V ; - struct adjList *array; -}; -struct adjListNode * newAdjNode(int dest, int wt) -{ - struct adjListNode *newNode = (struct adjListNode* )malloc(sizeof(struct adjListNode)); - newNode->dest = dest; - newNode->wt = wt; - newNode->next = NULL ; - return newNode; -} -struct Graph* createGraph(int V,int E) -{ - int i ; - struct Graph* G = (struct Graph *)malloc(sizeof(struct Graph)); - G->V = V ; - G->array = (struct adjList*)malloc(E*sizeof(struct adjList)); - fr(i,0,V) - { - G->array[i].head = NULL ; - } - return G ; -} -void addEdge(struct Graph *G,int src, int dest, int wt) -{ - struct adjListNode*temp=newAdjNode(dest,wt); - temp->next=G->array[src].head; - G->array[src].head=temp; - - temp=newAdjNode(src,wt); - temp->next=G->array[dest].head; - G->array[dest].head=temp; -} -struct MinHeapNode -{ - int v; - int dist; -}; -struct MinHeap -{ - int size; - int capacity; - int *pos; - struct MinHeapNode **array; -}; -struct MinHeapNode* newMinHeapNode(int v, int dist) -{ - struct MinHeapNode* minHeapNode = - (struct MinHeapNode*) malloc(sizeof(struct MinHeapNode)); - minHeapNode->v = v; - minHeapNode->dist = dist; - return minHeapNode; -} -struct MinHeap* createMinHeap(int capacity) -{ - struct MinHeap* minHeap = - (struct MinHeap*) malloc(sizeof(struct MinHeap)); - minHeap->pos = (int *)malloc(capacity * sizeof(int)); - minHeap->size = 0; - minHeap->capacity = capacity; - minHeap->array = - (struct MinHeapNode**) malloc(capacity * sizeof(struct MinHeapNode*)); - return minHeap; -} -void swapMinHeapNode(struct MinHeapNode** a, struct MinHeapNode** b) -{ - struct MinHeapNode* t = *a; - *a = *b; - *b = t; -} -void minHeapify(struct MinHeap* minHeap, int idx) -{ - int smallest, left, right; - smallest = idx; - left = 2 * idx + 1; - right = 2 * idx + 2; - - if (left < minHeap->size && - minHeap->array[left]->dist < minHeap->array[smallest]->dist ) - smallest = left; - - if (right < minHeap->size && - minHeap->array[right]->dist < minHeap->array[smallest]->dist ) - smallest = right; - - if (smallest != idx) - { - MinHeapNode *smallestNode = minHeap->array[smallest]; - MinHeapNode *idxNode = minHeap->array[idx]; - - minHeap->pos[smallestNode->v] = idx; - minHeap->pos[idxNode->v] = smallest; - - swapMinHeapNode(&minHeap->array[smallest], &minHeap->array[idx]); - - minHeapify(minHeap, smallest); - } -} - -int isEmpty(struct MinHeap* minHeap) -{ - return minHeap->size == 0; -} - -struct MinHeapNode* extractMin(struct MinHeap* minHeap) -{ - if (isEmpty(minHeap)) - return NULL; - - struct MinHeapNode* root = minHeap->array[0]; - - struct MinHeapNode* lastNode = minHeap->array[minHeap->size - 1]; - minHeap->array[0] = lastNode; - - minHeap->pos[root->v] = minHeap->size-1; - minHeap->pos[lastNode->v] = 0; - - --minHeap->size; - minHeapify(minHeap, 0); - - return root; -} - -void decreaseKey(struct MinHeap* minHeap, int v, int dist) -{ - int i = minHeap->pos[v]; - - minHeap->array[i]->dist = dist; - - while (i && minHeap->array[i]->dist < minHeap->array[(i - 1) / 2]->dist) - { - minHeap->pos[minHeap->array[i]->v] = (i-1)/2; - minHeap->pos[minHeap->array[(i-1)/2]->v] = i; - swapMinHeapNode(&minHeap->array[i], &minHeap->array[(i - 1) / 2]); - i = (i - 1) / 2; - } -} - -bool isInMinHeap(struct MinHeap *minHeap, int v) -{ - if (minHeap->pos[v] < minHeap->size) - return true; - return false; -} -void printarr(int dist[], int v , int src) -{ - int i ; - fr(i,0,v) - { - if(i==src) - continue; - if(dist[i] == infinite) - dist[i] = -1 ; - cout<V; - int dist[V]; - struct MinHeap * minHeap = createMinHeap(V); - fr(i,0,V) - { - dist[i] = infinite ; - minHeap->array[i] = newMinHeapNode(i,dist[i]); - minHeap->pos[i] = i ; - } - minHeap->array[src] = newMinHeapNode(src,dist[src]) ; - minHeap->pos[src] = src ; - dist[src] = 0 ; - decreaseKey(minHeap,src,dist[src]); - minHeap->size = V ; - while(!isEmpty(minHeap)) - { - struct MinHeapNode* minHeapNode = extractMin(minHeap); - int u = minHeapNode->v; - struct adjListNode* pCrawl = G->array[u].head; - while (pCrawl != NULL) - { - int v = pCrawl->dest; - if (isInMinHeap(minHeap, v) && dist[u] != INT_MAX && pCrawl->wt + dist[u] < dist[v]) - { - dist[v] = dist[u] + pCrawl->wt; - decreaseKey(minHeap, v, dist[v]); - } - pCrawl = pCrawl->next; - } - } - printarr(dist,V,src); -} -int main(void) -{ - int test,v,e,a,b,wt; - cin>>test; - while(test--) - { - cin>>v>>e; - struct Graph* G = createGraph(v,e); - while(e--) - { - cin>>a>>b>>wt; - addEdge(G,a-1,b-1,wt); - } - cin>>a; - dijsktra(G,a-1); - } - return 0; -} \ No newline at end of file diff --git a/binaryIndexedTree/Reference.txt b/binaryIndexedTree/Reference.txt deleted file mode 100644 index e7a6004fd..000000000 --- a/binaryIndexedTree/Reference.txt +++ /dev/null @@ -1,3 +0,0 @@ -Here are some websites/blogs which inspired and motivated this concept in me. -https://kartikkukreja.wordpress.com/2013/12/02/range-updates-with-bit-fenwick-tree/ -http://zobayer.blogspot.in/2013/11/various-usage-of-bit.html diff --git a/binaryIndexedTree/SPOJ_ctrick.cpp b/binaryIndexedTree/SPOJ_ctrick.cpp deleted file mode 100644 index 54660c92a..000000000 --- a/binaryIndexedTree/SPOJ_ctrick.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include -#include -using namespace std; -#define lli long long int -#define Min(a,b) (a 0){ - sum += T[index] ; - index = index - (index&(-1*index)); - } - return sum ; -} -void update(lli T[] , lli n , lli index , lli value ){ - index++; - while(index <= n){ - T[index] += value ; - index = index + (index&(-1*index)); - } -} -lli * binary_indexed_tree(lli n){ - lli i ; - lli* T =(lli *) malloc(sizeof(lli)*200002) ; - for(i = 1 ; i <= n+1 ; i++) - { - T[i] = 0 ; - } - for(i = 0 ; i < n ; i++) - { - update(T,n,i,1) ; - } - return T ; -} -void renew(lli* T,lli n) -{ - lli i ; - for(i = 1 ; i <= n+1 ; i++) - { - T[i] = 0 ; - } - for(i = 0 ; i < n ; i++) - { - update(T,n,i,1) ; - } -} - -lli modified_binary_search(lli * T, lli val, lli start , lli end) -{ - lli mid = (start+end)/2 ; - lli mid_sum = sum(T,mid) ; - if((mid_sum == val)&&(hash_array_mod[mid+1] == 0)) - return mid; - else if( (mid_sum > val) || ((mid_sum == val)&&(hash_array_mod[mid+1] != 0)) ) - { - return modified_binary_search(T,val,start,mid-1); - } - else - { - return modified_binary_search(T,val,mid+1,end); - } -} -int main() { - lli test,n,i,j,ans,current_pos,next_pos_sum,next_pos,count,free_space_total; - lli a[200002]; - cin>>test; - lli* T = binary_indexed_tree(n); - while(test--) - { - cin>>n; - //cin>>query; - if(n == 1) - { - cout<<"1"< -#include -#include -#include -#include -using namespace std; -#define lli long long int -#define Min(a,b) (a s ; i--) - -//lli sum( lli index) : returns of arr[index]+arr[index-1]..arr[0] - -//void update( lli n , lli index , lli value ) : adds v to arr[index] - - -lli T[100002]={0} ; -lli sum(lli index){ - lli sum = 0; - index+=1; - while(index > 0){ - sum += T[index] ; - index = index - (index&(-1*index)); - } - return sum ; -} -void update(lli n , lli index , lli value ){ - index++; - while(index <= n){ - T[index] += value ; - index = index + (index&(-1*index)); - } -} -void binary_indexed_tree(lli *a, lli n){ - lli i ; - for(i = 1 ; i <= n+1 ; i++) - { - T[i] = 0 ; - } - //To be Uncommented as per the need - /*for(i = 0 ; i < n ; i++) - { - update(n,i,a[i]) ; - }*/ -} -int main() { - lli test,n,i,j,inversions,position,option,ans,p,q,v; - lli arr[100002]; - lli brr[100002]; - cin>>test; - while(test--) - { - inversions = 0; - cin>>n; - fr(i,0,n) - { - cin>>arr[i]; - brr[i] = arr[i] ; - } - sort(brr,brr+n); - fr(i,0,n) - { - position = ( lli )(lower_bound(brr,brr+n,arr[i])-brr); - arr[i] = position+1 ; - } - binary_indexed_tree(arr,n); - ufr(i,n-1,-1) - { - inversions += sum(arr[i]-1); - update(n,arr[i],1); - } - cout< -#include -#include -#include -#include -using namespace std; -#define lli long long int -#define Min(a,b) (a 0){ - sum += T[index] ; - index = index - (index&(-1*index)); - } - return sum ; -} -void update(lli n , lli index , lli value ){ - index++; - while(index <= n){ - T[index] += value ; - index = index + (index&(-1*index)); - } -} -lli * binary_indexed_tree(lli *a, lli n){ - lli i ; - for(i = 1 ; i <= n+1 ; i++) - { - T[i] = 0 ; - } - for(i = 0 ; i < n ; i++) - { - update(n,i,a[i]) ; - } - return T ; -} -int main() { - lli test,n,i,j,query,option,ans,p,q,v; - lli arr[200002]; - cin>>test; - while(test--) - { - cin>>n; - cin>>query; - fr(i,0,n) - { - arr[i] = 0; - } - binary_indexed_tree(arr,n); - while(query--) - { - cin>>option>>p>>q ; - p--; - q--; - if(option == 0) - { - cin>>v; - update(n,p,v); - if(q != n-1) - update(n,q+1,-1*v); - } - else - { - if(p == 0) - ans = sum(q); - else - ans = sum(q)-sum(p-1) ; - cout< -#include -#include -#include -#include -using namespace std; -#define lli long long int -#define Min(a,b) (a 0){ - sum += T[index] ; - index = index - (index&(-1*index)); - } - return sum ; -} -void update(lli T[] , lli n , lli index , lli value ){ - index++; - while(index <= n){ - T[index] += value ; - index = index + (index&(-1*index)); - } -} -lli * binary_indexed_tree(lli n){ - lli i ; - lli* T =(lli *) malloc(sizeof(lli)*200002) ; - for(i = 1 ; i <= n+1 ; i++) - { - T[i] = 0 ; - } - // for(i = 0 ; i < n ; i++) - // { - // update(T,n,i,a[i]) ; - // } - return T ; -} -int main() { - lli test,n,i,j,query,option,ans,p,q,v; - lli arr[200002]; - cin>>test; - while(test--) - { - cin>>n; - cin>>query; - fr(i,0,n) - { - arr[i] = 0; - } - lli* T1 = binary_indexed_tree(n); - lli* T2 = binary_indexed_tree(n); - while(query--) - { - cin>>option>>p>>q ; - p--; - q--; - if(option == 0) - { - cin>>v; - update(T1,n,p,v); - update(T1,n,q+1,-v); - update(T2,n,p,v*(p-1)); - update(T2,n,q+1,-v*q); - } - else - { - ans = sum(T1,q)*q-sum(T2,q)-sum(T1,p-1)*(p-1)+sum(T2,p-1) ; - cout< -using namespace std; -const int inf=0x3fffffff; -#define Min(a,b) (a>test ; - while(test--) - { - cin>>a; - cin>>b; - cin>>z; - cin>>x; - cin>>c; - lena = strlen(a) ; - lenb = strlen(b) ; - if((lena-lenb)*z > c || (lenb-lena)*z > c ) - { - cout<<"-1\n"; - continue ; - } - if( (z == 0) ) - { - cout<<"0\n" ; - continue ; - } - if( (x == 0) ) - { - cout< c) - previous_dp[i] = inf ; - else - previous_dp[i] = i*z ; - } - fr(i,1,lena+1) - { - alpha = Max((i-c),0) ; - if( alpha > 0) - { - current_dp[alpha-1] = inf ; - } - alpha -= 1 ; - temp = Min((i+c+1),(lenb+1)); - fr(j,alpha+1,temp) - { - if(j == 0) - { - current_dp[j] = i*z ; - } - else - { - current_dp[j] = Min(Min(previous_dp[j] + z , current_dp[j-1] + z ) , previous_dp[j-1]+(a[i-1] == b[j-1] ? 0 : x)); - } - } - fr(j,alpha,temp) - { - previous_dp[j] = current_dp[j] ; - } - } - if(current_dp[lenb] > c) - cout<<"-1\n"; - else - cout< -using namespace std; -#define Min(a,b) (a>test ; - while(test--) - { - cin>>a; - cin>>b; - lena = strlen(a) ; - lenb = strlen(b) ; - dp[lena+1][lenb+1]; - fr(i,0,lena+1) - { - fr(j,0,lenb+1) - { - if( i == 0 ) - { - dp[i][j] = j ; - } - else if( j == 0 ) - { - dp[i][j] = i ; - } - else - { - dp[i][j]=Min(Min(dp[i-1][j]+1,dp[i][j-1]+1),dp[i-1][j-1]+(a[i-1]==b[j-1]?0:100)); - } - cout<Pnm3MlAO3{oF|H;EH)I$ zk&m7nAgK*mX<1pRvCV-y><@1!umMAspc@J=Lv7j4;tWVJr&x=kO$#Ai1}Sm^H%(JD zO|1RSz4wrhPh=N#!2X%8z<2KX-E+=8_q_Y@?t52X?&{fB<#Gv5RpRr4xC^yG38^di z2FYryO{@|@u}N$cD}dDC7nCJLRgUR`HqEqF%eg_T@oTG6KwDK%W|)3b!GbA!NR;X;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55ebf2 Mon Sep 17 00:00:00 2001 From: smitbose Date: Sun, 25 Dec 2016 19:00:46 +0530 Subject: [PATCH 17/32] Created jekyll structure --- .gitignore | 3 ++ Gemfile | 24 +++++++++ Gemfile.lock | 56 ++++++++++++++++++++ _config.yml | 34 ++++++++++++ _posts/2016-12-25-welcome-to-jekyll.markdown | 25 +++++++++ about.md | 15 ++++++ index.md | 6 +++ 7 files changed, 163 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 _config.yml create mode 100644 _posts/2016-12-25-welcome-to-jekyll.markdown create mode 100644 about.md create mode 100644 index.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..45c150536 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +_site +.sass-cache +.jekyll-metadata diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..5202882a2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,24 @@ +source "https://rubygems.org" +ruby RUBY_VERSION + +# Hello! This is where you manage which Jekyll version is used to run. +# When you want to use a different version, change it below, save the +# file and run `bundle install`. Run Jekyll with `bundle exec`, like so: +# +# bundle exec jekyll serve +# +# This will help ensure the proper Jekyll version is running. +# Happy Jekylling! +gem "jekyll", "3.3.1" + +# This is the default theme for new Jekyll sites. You may change this to anything you like. +gem "minima", "~> 2.0" + +# If you want to use GitHub Pages, remove the "gem "jekyll"" above and +# uncomment the line below. To upgrade, run `bundle update github-pages`. +# gem "github-pages", group: :jekyll_plugins + +# If you have any plugins, put them here! +group :jekyll_plugins do + gem "jekyll-feed", "~> 0.6" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..f1c082640 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,56 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.5.0) + public_suffix (~> 2.0, >= 2.0.2) + colorator (1.1.0) + ffi (1.9.14) + forwardable-extended (2.6.0) + jekyll (3.3.1) + addressable (~> 2.4) + colorator (~> 1.0) + jekyll-sass-converter (~> 1.0) + jekyll-watch (~> 1.1) + kramdown (~> 1.3) + liquid (~> 3.0) + mercenary (~> 0.3.3) + pathutil (~> 0.9) + rouge (~> 1.7) + safe_yaml (~> 1.0) + jekyll-feed (0.8.0) + jekyll (~> 3.3) + jekyll-sass-converter (1.5.0) + sass (~> 3.4) + jekyll-watch (1.5.0) + listen (~> 3.0, < 3.1) + kramdown (1.13.1) + liquid (3.0.6) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + mercenary (0.3.6) + minima (2.1.0) + jekyll (~> 3.3) + pathutil (0.14.0) + forwardable-extended (~> 2.6) + public_suffix (2.0.4) + rb-fsevent (0.9.8) + rb-inotify (0.9.7) + ffi (>= 0.5.0) + rouge (1.11.1) + safe_yaml (1.0.4) + sass (3.4.23) + +PLATFORMS + ruby + +DEPENDENCIES + jekyll (= 3.3.1) + jekyll-feed (~> 0.6) + minima (~> 2.0) + +RUBY VERSION + ruby 2.3.3p222 + +BUNDLED WITH + 1.13.6 diff --git a/_config.yml b/_config.yml new file mode 100644 index 000000000..f5df98308 --- /dev/null +++ b/_config.yml @@ -0,0 +1,34 @@ +# Welcome to Jekyll! +# +# This config file is meant for settings that affect your whole blog, values +# which you are expected to set up once and rarely edit after that. If you find +# yourself editing this file very often, consider using Jekyll's data files +# feature for the data you need to update frequently. +# +# For technical reasons, this file is *NOT* reloaded automatically when you use +# 'bundle exec jekyll serve'. If you change this file, please restart the server process. + +# Site settings +# These are used to personalize your new site. If you look in the HTML files, +# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. +# You can create any custom variable you would like, and they will be accessible +# in the templates via {{ site.myvariable }}. +title: Your awesome title +email: your-email@domain.com +description: > # this means to ignore newlines until "baseurl:" + Write an awesome description for your new site here. You can edit this + line in _config.yml. It will appear in your document head meta (for + Google search results) and in your feed.xml site description. +baseurl: "" # the subpath of your site, e.g. /blog +url: "" # the base hostname & protocol for your site, e.g. http://example.com +twitter_username: jekyllrb +github_username: jekyll + +# Build settings +markdown: kramdown +theme: minima +gems: + - jekyll-feed +exclude: + - Gemfile + - Gemfile.lock diff --git a/_posts/2016-12-25-welcome-to-jekyll.markdown b/_posts/2016-12-25-welcome-to-jekyll.markdown new file mode 100644 index 000000000..9c7eef354 --- /dev/null +++ b/_posts/2016-12-25-welcome-to-jekyll.markdown @@ -0,0 +1,25 @@ +--- +layout: post +title: "Welcome to Jekyll!" +date: 2016-12-25 18:58:43 +0530 +categories: jekyll update +--- +You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated. + +To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works. + +Jekyll also offers powerful support for code snippets: + +{% highlight ruby %} +def print_hi(name) + puts "Hi, #{name}" +end +print_hi('Tom') +#=> prints 'Hi, Tom' to STDOUT. +{% endhighlight %} + +Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk]. + +[jekyll-docs]: http://jekyllrb.com/docs/home +[jekyll-gh]: https://github.com/jekyll/jekyll +[jekyll-talk]: https://talk.jekyllrb.com/ diff --git a/about.md b/about.md new file mode 100644 index 000000000..19d6b978b --- /dev/null +++ b/about.md @@ -0,0 +1,15 @@ +--- +layout: page +title: About +permalink: /about/ +--- + +This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](http://jekyllrb.com/) + +You can find the source code for the Jekyll new theme at: +{% include icon-github.html username="jekyll" %} / +[minima](https://github.com/jekyll/minima) + +You can find the source code for Jekyll at +{% include icon-github.html username="jekyll" %} / +[jekyll](https://github.com/jekyll/jekyll) diff --git a/index.md b/index.md new file mode 100644 index 000000000..1eb5d6724 --- /dev/null +++ b/index.md @@ -0,0 +1,6 @@ +--- +# You don't need to edit this file, it's empty on purpose. +# Edit theme's home layout instead if you wanna make some changes +# See: https://jekyllrb.com/docs/themes/#overriding-theme-defaults +layout: home +--- From 79775bfae4908db30b26d069256867814e153648 Mon Sep 17 00:00:00 2001 From: smitbose Date: Sun, 25 Dec 2016 19:58:24 +0530 Subject: [PATCH 18/32] Added minima structure --- _includes/disqus_comments.html | 20 +++ _includes/footer.html | 46 +++++ _includes/google-analytics.html | 11 ++ _includes/head.html | 16 ++ _includes/header.html | 27 +++ _includes/icon-github.html | 1 + _includes/icon-github.svg | 1 + _includes/icon-twitter.html | 1 + _includes/icon-twitter.svg | 1 + _layouts/default.html | 20 +++ _layouts/home.html | 25 +++ _layouts/page.html | 14 ++ _layouts/post.html | 18 ++ _sass/minima.scss | 43 +++++ _sass/minima/_base.scss | 198 +++++++++++++++++++++ _sass/minima/_layout.scss | 237 +++++++++++++++++++++++++ _sass/minima/_syntax-highlighting.scss | 71 ++++++++ 17 files changed, 750 insertions(+) create mode 100644 _includes/disqus_comments.html create mode 100644 _includes/footer.html create mode 100644 _includes/google-analytics.html create mode 100644 _includes/head.html create mode 100644 _includes/header.html create mode 100644 _includes/icon-github.html create mode 100644 _includes/icon-github.svg create mode 100644 _includes/icon-twitter.html create mode 100644 _includes/icon-twitter.svg create mode 100644 _layouts/default.html create mode 100644 _layouts/home.html create mode 100644 _layouts/page.html create mode 100644 _layouts/post.html create mode 100644 _sass/minima.scss create mode 100644 _sass/minima/_base.scss create mode 100644 _sass/minima/_layout.scss create mode 100644 _sass/minima/_syntax-highlighting.scss diff --git a/_includes/disqus_comments.html b/_includes/disqus_comments.html new file mode 100644 index 000000000..87fa30942 --- /dev/null +++ b/_includes/disqus_comments.html @@ -0,0 +1,20 @@ +{% if page.comments != false and jekyll.environment == "production" %} + +
+ + +{% endif %} diff --git a/_includes/footer.html b/_includes/footer.html new file mode 100644 index 000000000..dc26507ab --- /dev/null +++ b/_includes/footer.html @@ -0,0 +1,46 @@ +
+ +
+ + + + + +
+ +
diff --git a/_includes/google-analytics.html b/_includes/google-analytics.html new file mode 100644 index 000000000..eb2a692a5 --- /dev/null +++ b/_includes/google-analytics.html @@ -0,0 +1,11 @@ + + diff --git a/_includes/head.html b/_includes/head.html new file mode 100644 index 000000000..99b698fc8 --- /dev/null +++ b/_includes/head.html @@ -0,0 +1,16 @@ + + + + + + {% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %} + + + + + + + {% if jekyll.environment == 'production' and site.google_analytics %} + {% include google-analytics.html %} + {% endif %} + diff --git a/_includes/header.html b/_includes/header.html new file mode 100644 index 000000000..df0de2527 --- /dev/null +++ b/_includes/header.html @@ -0,0 +1,27 @@ + diff --git a/_includes/icon-github.html b/_includes/icon-github.html new file mode 100644 index 000000000..e501a16b1 --- /dev/null +++ b/_includes/icon-github.html @@ -0,0 +1 @@ +{% include icon-github.svg %}{{ include.username }} diff --git a/_includes/icon-github.svg b/_includes/icon-github.svg new file mode 100644 index 000000000..e6c5f6dfd --- /dev/null +++ b/_includes/icon-github.svg @@ -0,0 +1 @@ + diff --git a/_includes/icon-twitter.html b/_includes/icon-twitter.html new file mode 100644 index 000000000..e623dbd6e --- /dev/null +++ b/_includes/icon-twitter.html @@ -0,0 +1 @@ +{{ include.username }} diff --git a/_includes/icon-twitter.svg b/_includes/icon-twitter.svg new file mode 100644 index 000000000..efc0ecf67 --- /dev/null +++ b/_includes/icon-twitter.svg @@ -0,0 +1 @@ + diff --git a/_layouts/default.html b/_layouts/default.html new file mode 100644 index 000000000..52085bfa2 --- /dev/null +++ b/_layouts/default.html @@ -0,0 +1,20 @@ + + + + {% include head.html %} + + + + {% include header.html %} + +
+
+ {{ content }} +
+
+ + {% include footer.html %} + + + + diff --git a/_layouts/home.html b/_layouts/home.html new file mode 100644 index 000000000..7b15fecec --- /dev/null +++ b/_layouts/home.html @@ -0,0 +1,25 @@ +--- +layout: default +--- + +
+ +

Posts

+ + {{ content }} + +
    + {% for post in site.posts %} +
  • + + +

    + {{ post.title | escape }} +

    +
  • + {% endfor %} +
+ +

subscribe via RSS

+ +
diff --git a/_layouts/page.html b/_layouts/page.html new file mode 100644 index 000000000..01e4b2a93 --- /dev/null +++ b/_layouts/page.html @@ -0,0 +1,14 @@ +--- +layout: default +--- +
+ +
+

{{ page.title | escape }}

+
+ +
+ {{ content }} +
+ +
diff --git a/_layouts/post.html b/_layouts/post.html new file mode 100644 index 000000000..1d36c2828 --- /dev/null +++ b/_layouts/post.html @@ -0,0 +1,18 @@ +--- +layout: default +--- +
+ +
+

{{ page.title | escape }}

+ +
+ +
+ {{ content }} +
+ + {% if site.disqus.shortname %} + {% include disqus_comments.html %} + {% endif %} +
diff --git a/_sass/minima.scss b/_sass/minima.scss new file mode 100644 index 000000000..29b37004e --- /dev/null +++ b/_sass/minima.scss @@ -0,0 +1,43 @@ +// Define defaults for each variable. + +$base-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !default; +$base-font-size: 16px !default; +$base-font-weight: 400 !default; +$small-font-size: $base-font-size * 0.875 !default; +$base-line-height: 1.5 !default; + +$spacing-unit: 30px !default; + +$text-color: #111 !default; +$background-color: #fdfdfd !default; +$brand-color: #2a7ae2 !default; + +$grey-color: #828282 !default; +$grey-color-light: lighten($grey-color, 40%) !default; +$grey-color-dark: darken($grey-color, 25%) !default; + +// Width of the content area +$content-width: 800px !default; + +$on-palm: 600px !default; +$on-laptop: 800px !default; + +// Use media queries like this: +// @include media-query($on-palm) { +// .wrapper { +// padding-right: $spacing-unit / 2; +// padding-left: $spacing-unit / 2; +// } +// } +@mixin media-query($device) { + @media screen and (max-width: $device) { + @content; + } +} + +// Import partials. +@import + "minima/base", + "minima/layout", + "minima/syntax-highlighting" +; diff --git a/_sass/minima/_base.scss b/_sass/minima/_base.scss new file mode 100644 index 000000000..06bc9ae14 --- /dev/null +++ b/_sass/minima/_base.scss @@ -0,0 +1,198 @@ +/** + * Reset some basic elements + */ +body, h1, h2, h3, h4, h5, h6, +p, blockquote, pre, hr, +dl, dd, ol, ul, figure { + margin: 0; + padding: 0; +} + + + +/** + * Basic styling + */ +body { + font: $base-font-weight #{$base-font-size}/#{$base-line-height} $base-font-family; + color: $text-color; + background-color: $background-color; + -webkit-text-size-adjust: 100%; + -webkit-font-feature-settings: "kern" 1; + -moz-font-feature-settings: "kern" 1; + -o-font-feature-settings: "kern" 1; + font-feature-settings: "kern" 1; + font-kerning: normal; +} + + + +/** + * Set `margin-bottom` to maintain vertical rhythm + */ +h1, h2, h3, h4, h5, h6, +p, blockquote, pre, +ul, ol, dl, figure, +%vertical-rhythm { + margin-bottom: $spacing-unit / 2; +} + + + +/** + * Images + */ +img { + max-width: 100%; + vertical-align: middle; +} + + + +/** + * Figures + */ +figure > img { + display: block; +} + +figcaption { + font-size: $small-font-size; +} + + + +/** + * Lists + */ +ul, ol { + margin-left: $spacing-unit; +} + +li { + > ul, + > ol { + margin-bottom: 0; + } +} + + + +/** + * Headings + */ +h1, h2, h3, h4, h5, h6 { + font-weight: $base-font-weight; +} + + + +/** + * Links + */ +a { + color: $brand-color; + text-decoration: none; + + &:visited { + color: darken($brand-color, 15%); + } + + &:hover { + color: $text-color; + text-decoration: underline; + } +} + + + +/** + * Blockquotes + */ +blockquote { + color: $grey-color; + border-left: 4px solid $grey-color-light; + padding-left: $spacing-unit / 2; + font-size: 18px; + letter-spacing: -1px; + font-style: italic; + + > :last-child { + margin-bottom: 0; + } +} + + + +/** + * Code formatting + */ +pre, +code { + font-size: 15px; + border: 1px solid $grey-color-light; + border-radius: 3px; + background-color: #eef; +} + +code { + padding: 1px 5px; +} + +pre { + padding: 8px 12px; + overflow-x: auto; + + > code { + border: 0; + padding-right: 0; + padding-left: 0; + } +} + + + +/** + * Wrapper + */ +.wrapper { + max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit} * 2)); + max-width: calc(#{$content-width} - (#{$spacing-unit} * 2)); + margin-right: auto; + margin-left: auto; + padding-right: $spacing-unit; + padding-left: $spacing-unit; + @extend %clearfix; + + @include media-query($on-laptop) { + max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit})); + max-width: calc(#{$content-width} - (#{$spacing-unit})); + padding-right: $spacing-unit / 2; + padding-left: $spacing-unit / 2; + } +} + + + +/** + * Clearfix + */ +%clearfix:after { + content: ""; + display: table; + clear: both; +} + + + +/** + * Icons + */ +.icon > svg { + display: inline-block; + vertical-align: middle; + + path { + fill: $grey-color; + } +} diff --git a/_sass/minima/_layout.scss b/_sass/minima/_layout.scss new file mode 100644 index 000000000..11b04583a --- /dev/null +++ b/_sass/minima/_layout.scss @@ -0,0 +1,237 @@ +/** + * Site header + */ +.site-header { + border-top: 5px solid $grey-color-dark; + border-bottom: 1px solid $grey-color-light; + min-height: 56px; + + // Positioning context for the mobile navigation icon + position: relative; +} + +.site-title { + font-size: 26px; + font-weight: 300; + line-height: 56px; + letter-spacing: -1px; + margin-bottom: 0; + float: left; + + &, + &:visited { + color: $grey-color-dark; + } +} + +.site-nav { + float: right; + line-height: 56px; + + .menu-icon { + display: none; + } + + .page-link { + color: $text-color; + line-height: $base-line-height; + + // Gaps between nav items, but not on the last one + &:not(:last-child) { + margin-right: 20px; + } + } + + @include media-query($on-palm) { + position: absolute; + top: 9px; + right: $spacing-unit / 2; + background-color: $background-color; + border: 1px solid $grey-color-light; + border-radius: 5px; + text-align: right; + + .menu-icon { + display: block; + float: right; + width: 36px; + height: 26px; + line-height: 0; + padding-top: 10px; + text-align: center; + + > svg path { + fill: $grey-color-dark; + } + } + + .trigger { + clear: both; + display: none; + } + + &:hover .trigger { + display: block; + padding-bottom: 5px; + } + + .page-link { + display: block; + padding: 5px 10px; + + &:not(:last-child) { + margin-right: 0; + } + margin-left: 20px; + } + } +} + + + +/** + * Site footer + */ +.site-footer { + border-top: 1px solid $grey-color-light; + padding: $spacing-unit 0; +} + +.footer-heading { + font-size: 18px; + margin-bottom: $spacing-unit / 2; +} + +.contact-list, +.social-media-list { + list-style: none; + margin-left: 0; +} + +.footer-col-wrapper { + font-size: 15px; + color: $grey-color; + margin-left: -$spacing-unit / 2; + @extend %clearfix; +} + +.footer-col { + float: left; + margin-bottom: $spacing-unit / 2; + padding-left: $spacing-unit / 2; +} + +.footer-col-1 { + width: -webkit-calc(35% - (#{$spacing-unit} / 2)); + width: calc(35% - (#{$spacing-unit} / 2)); +} + +.footer-col-2 { + width: -webkit-calc(20% - (#{$spacing-unit} / 2)); + width: calc(20% - (#{$spacing-unit} / 2)); +} + +.footer-col-3 { + width: -webkit-calc(45% - (#{$spacing-unit} / 2)); + width: calc(45% - (#{$spacing-unit} / 2)); +} + +@include media-query($on-laptop) { + .footer-col-1, + .footer-col-2 { + width: -webkit-calc(50% - (#{$spacing-unit} / 2)); + width: calc(50% - (#{$spacing-unit} / 2)); + } + + .footer-col-3 { + width: -webkit-calc(100% - (#{$spacing-unit} / 2)); + width: calc(100% - (#{$spacing-unit} / 2)); + } +} + +@include media-query($on-palm) { + .footer-col { + float: none; + width: -webkit-calc(100% - (#{$spacing-unit} / 2)); + width: calc(100% - (#{$spacing-unit} / 2)); + } +} + + + +/** + * Page content + */ +.page-content { + padding: $spacing-unit 0; +} + +.page-heading { + font-size: 20px; +} + +.post-list { + margin-left: 0; + list-style: none; + + > li { + margin-bottom: $spacing-unit; + } +} + +.post-meta { + font-size: $small-font-size; + color: $grey-color; +} + +.post-link { + display: block; + font-size: 24px; +} + + + +/** + * Posts + */ +.post-header { + margin-bottom: $spacing-unit; +} + +.post-title { + font-size: 42px; + letter-spacing: -1px; + line-height: 1; + + @include media-query($on-laptop) { + font-size: 36px; + } +} + +.post-content { + margin-bottom: $spacing-unit; + + h2 { + font-size: 32px; + + @include media-query($on-laptop) { + font-size: 28px; + } + } + + h3 { + font-size: 26px; + + @include media-query($on-laptop) { + font-size: 22px; + } + } + + h4 { + font-size: 20px; + + @include media-query($on-laptop) { + font-size: 18px; + } + } +} diff --git a/_sass/minima/_syntax-highlighting.scss b/_sass/minima/_syntax-highlighting.scss new file mode 100644 index 000000000..bccdb8995 --- /dev/null +++ b/_sass/minima/_syntax-highlighting.scss @@ -0,0 +1,71 @@ +/** + * Syntax highlighting styles + */ +.highlight { + background: #fff; + @extend %vertical-rhythm; + + .highlighter-rouge & { + background: #eef; + } + + .c { color: #998; font-style: italic } // Comment + .err { color: #a61717; background-color: #e3d2d2 } // Error + .k { font-weight: bold } // Keyword + .o { font-weight: bold } // Operator + .cm { color: #998; font-style: italic } // Comment.Multiline + .cp { color: #999; font-weight: bold } // Comment.Preproc + .c1 { color: #998; font-style: italic } // Comment.Single + .cs { color: #999; font-weight: bold; font-style: italic } // Comment.Special + .gd { color: #000; background-color: #fdd } // Generic.Deleted + .gd .x { color: #000; background-color: #faa } // Generic.Deleted.Specific + .ge { font-style: italic } // Generic.Emph + .gr { color: #a00 } // Generic.Error + .gh { color: #999 } // Generic.Heading + .gi { color: #000; background-color: #dfd } // Generic.Inserted + .gi .x { color: #000; background-color: #afa } // Generic.Inserted.Specific + .go { color: #888 } // Generic.Output + .gp { color: #555 } // Generic.Prompt + .gs { font-weight: bold } // Generic.Strong + .gu { color: #aaa } // Generic.Subheading + .gt { color: #a00 } // Generic.Traceback + .kc { font-weight: bold } // Keyword.Constant + .kd { font-weight: bold } // Keyword.Declaration + .kp { font-weight: bold } // Keyword.Pseudo + .kr { font-weight: bold } // Keyword.Reserved + .kt { color: #458; font-weight: bold } // Keyword.Type + .m { color: #099 } // Literal.Number + .s { color: #d14 } // Literal.String + .na { color: #008080 } // Name.Attribute + .nb { color: #0086B3 } // Name.Builtin + .nc { color: #458; font-weight: bold } // Name.Class + .no { color: #008080 } // Name.Constant + .ni { color: #800080 } // Name.Entity + .ne { color: #900; font-weight: bold } // Name.Exception + .nf { color: #900; font-weight: bold } // Name.Function + .nn { color: #555 } // Name.Namespace + .nt { color: #000080 } // Name.Tag + .nv { color: #008080 } // Name.Variable + .ow { font-weight: bold } // Operator.Word + .w { color: #bbb } // Text.Whitespace + .mf { color: #099 } // Literal.Number.Float + .mh { color: #099 } // Literal.Number.Hex + .mi { color: #099 } // Literal.Number.Integer + .mo { color: #099 } // Literal.Number.Oct + .sb { color: #d14 } // Literal.String.Backtick + .sc { color: #d14 } // Literal.String.Char + .sd { color: #d14 } // Literal.String.Doc + .s2 { color: #d14 } // Literal.String.Double + .se { color: #d14 } // Literal.String.Escape + .sh { color: #d14 } // Literal.String.Heredoc + .si { color: #d14 } // Literal.String.Interpol + .sx { color: #d14 } // Literal.String.Other + .sr { color: #009926 } // Literal.String.Regex + .s1 { color: #d14 } // Literal.String.Single + .ss { color: #990073 } // Literal.String.Symbol + .bp { color: #999 } // Name.Builtin.Pseudo + .vc { color: #008080 } // Name.Variable.Class + .vg { color: #008080 } // Name.Variable.Global + .vi { color: #008080 } // Name.Variable.Instance + .il { color: #099 } // Literal.Number.Integer.Long +} From dd8b6d552391da9278e14f79407a502c2315d2ad Mon Sep 17 00:00:00 2001 From: smitbose Date: Sun, 25 Dec 2016 20:00:27 +0530 Subject: [PATCH 19/32] Modified about --- about.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/about.md b/about.md index 19d6b978b..fb074a698 100644 --- a/about.md +++ b/about.md @@ -4,12 +4,8 @@ title: About permalink: /about/ --- -This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](http://jekyllrb.com/) +This repository was created to list some popular algorithms, include tutorials, study materials and contain some implementations, to help students prepare for competitive coding events like ACM ICPC and also for placements. This website contains tutorials for various algorithms and for the corresponding implementation you can check out the repository [Algorithms](https://github.com/codeIIEST/Algorithms) under our [Github Organization](https://github.com/codeIIEST). -You can find the source code for the Jekyll new theme at: -{% include icon-github.html username="jekyll" %} / -[minima](https://github.com/jekyll/minima) +Also, this repository is currently growing, and we want this to always grow, including more and more algorithm implementations. So, you are free to contribute your implementations, making sure they are well documented for the reader to understand. -You can find the source code for Jekyll at -{% include icon-github.html username="jekyll" %} / -[jekyll](https://github.com/jekyll/jekyll) +Happy Coding! From 79cff522331c1c00cca77d6be3c02aaded89ed61 Mon Sep 17 00:00:00 2001 From: smitbose Date: Sun, 25 Dec 2016 21:35:22 +0530 Subject: [PATCH 20/32] changes to footer --- _config.yml | 10 +++----- _includes/footer.html | 51 +++++++++------------------------------ _layouts/home.html | 1 - _sass/minima/_layout.scss | 15 +++++++----- 4 files changed, 25 insertions(+), 52 deletions(-) diff --git a/_config.yml b/_config.yml index f5df98308..9c53ffef7 100644 --- a/_config.yml +++ b/_config.yml @@ -13,16 +13,14 @@ # you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. # You can create any custom variable you would like, and they will be accessible # in the templates via {{ site.myvariable }}. -title: Your awesome title +title: Algorithms email: your-email@domain.com description: > # this means to ignore newlines until "baseurl:" - Write an awesome description for your new site here. You can edit this - line in _config.yml. It will appear in your document head meta (for - Google search results) and in your feed.xml site description. + A repository of some popular algorithms baseurl: "" # the subpath of your site, e.g. /blog url: "" # the base hostname & protocol for your site, e.g. http://example.com -twitter_username: jekyllrb -github_username: jekyll +twitter_username: +github_username: codeIIEST # Build settings markdown: kramdown diff --git a/_includes/footer.html b/_includes/footer.html index dc26507ab..41a768091 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -1,46 +1,19 @@
- - - - + +
diff --git a/_layouts/home.html b/_layouts/home.html index 7b15fecec..82d1d9f81 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -20,6 +20,5 @@

{% endfor %} -

subscribe via RSS

diff --git a/_sass/minima/_layout.scss b/_sass/minima/_layout.scss index 11b04583a..407559fb3 100644 --- a/_sass/minima/_layout.scss +++ b/_sass/minima/_layout.scss @@ -122,18 +122,21 @@ } .footer-col-1 { - width: -webkit-calc(35% - (#{$spacing-unit} / 2)); - width: calc(35% - (#{$spacing-unit} / 2)); + text-align: left; + width: -webkit-calc(25% - (#{$spacing-unit} / 2)); + width: calc(25% - (#{$spacing-unit} / 2)); } .footer-col-2 { - width: -webkit-calc(20% - (#{$spacing-unit} / 2)); - width: calc(20% - (#{$spacing-unit} / 2)); + text-align: center; + width: -webkit-calc(50% - (#{$spacing-unit} / 2)); + width: calc(50% - (#{$spacing-unit} / 2)); } .footer-col-3 { - width: -webkit-calc(45% - (#{$spacing-unit} / 2)); - width: calc(45% - (#{$spacing-unit} / 2)); + text-align: right; + width: -webkit-calc(25% - (#{$spacing-unit} / 2)); + width: calc(25% - (#{$spacing-unit} / 2)); } @include media-query($on-laptop) { From a0fdcde655993bd89ebf6186a713cfcff4fc904b Mon Sep 17 00:00:00 2001 From: smitbose Date: Mon, 26 Dec 2016 13:07:13 +0530 Subject: [PATCH 21/32] Added categories --- _sass/minima/tabs.scss | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 _sass/minima/tabs.scss diff --git a/_sass/minima/tabs.scss b/_sass/minima/tabs.scss new file mode 100644 index 000000000..1f86088df --- /dev/null +++ b/_sass/minima/tabs.scss @@ -0,0 +1,26 @@ +div +{ + .category + { + border: 2px solid; + border-radius: 7px; + float: left; + text-align: left; + width: -webkit-calc(80%); + width: calc(80%); + background: #D3D3D3; + padding: 10px 5px 10px 20px; + box-shadow: 5px 5px 2px #888888; + margin: 5px 10% 5px 10%; + font-size: 12px; + h3 { + margin: 0px; + } + } + .category:hover + { + width: -webkit-calc(82%); + width: calc(82%); + padding: 11px 5px 11px 21px; + } +} From 60492e7e5435047dd3a4786322c7ec03a3d40fee Mon Sep 17 00:00:00 2001 From: smitbose Date: Mon, 26 Dec 2016 13:08:15 +0530 Subject: [PATCH 22/32] Added categories --- _layouts/home.html | 45 +++++++++++++++++++++++++++++---------------- _sass/minima.scss | 3 ++- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/_layouts/home.html b/_layouts/home.html index 82d1d9f81..c2adae124 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -4,21 +4,34 @@
-

Posts

+

Categories

- {{ content }} - -
    - {% for post in site.posts %} -
  • - - -

    - {{ post.title | escape }} -

    -
  • - {% endfor %} -
- - +
+

Searching

+ Searching an element from a set of elements +
+
+

Sorting

+ Sorting a set of elements in a particular order +
+
+

Stack and Queue

+ Algorithms that require FIFO or LIFO processing +
+
+

Trees

+ Segment trees, BITs and other algorithms for interval processing and searching +
+
+

Graphs

+ Modelling real life problems as a set of vertices and links between them +
+
+

Greedy and Dynamic Programming

+ Solving a bigger problem through solution of subproblems +
+
+

Others

+ Any algorithm that doesn't come under the above categories +
diff --git a/_sass/minima.scss b/_sass/minima.scss index 29b37004e..5372652f4 100644 --- a/_sass/minima.scss +++ b/_sass/minima.scss @@ -39,5 +39,6 @@ $on-laptop: 800px !default; @import "minima/base", "minima/layout", - "minima/syntax-highlighting" + "minima/syntax-highlighting", + "minima/tabs" ; From b843fc805431114774ea807c49e4069ca1290098 Mon Sep 17 00:00:00 2001 From: smitbose Date: Mon, 26 Dec 2016 15:52:50 +0530 Subject: [PATCH 23/32] Created graph category page --- _layouts/home.html | 2 +- _posts/2016-12-25-welcome-to-jekyll.markdown | 25 -------------------- _posts/graph/2016-12-26-test.markdown | 10 ++++++++ _posts/search/2016-12-26-test.markdown | 10 ++++++++ pages/graph.html | 21 ++++++++++++++++ 5 files changed, 42 insertions(+), 26 deletions(-) delete mode 100644 _posts/2016-12-25-welcome-to-jekyll.markdown create mode 100644 _posts/graph/2016-12-26-test.markdown create mode 100644 _posts/search/2016-12-26-test.markdown create mode 100644 pages/graph.html diff --git a/_layouts/home.html b/_layouts/home.html index c2adae124..8eca8c087 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -22,7 +22,7 @@

Stack and Queue

Trees

Segment trees, BITs and other algorithms for interval processing and searching -
+

Graphs

Modelling real life problems as a set of vertices and links between them
diff --git a/_posts/2016-12-25-welcome-to-jekyll.markdown b/_posts/2016-12-25-welcome-to-jekyll.markdown deleted file mode 100644 index 9c7eef354..000000000 --- a/_posts/2016-12-25-welcome-to-jekyll.markdown +++ /dev/null @@ -1,25 +0,0 @@ ---- -layout: post -title: "Welcome to Jekyll!" -date: 2016-12-25 18:58:43 +0530 -categories: jekyll update ---- -You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated. - -To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works. - -Jekyll also offers powerful support for code snippets: - -{% highlight ruby %} -def print_hi(name) - puts "Hi, #{name}" -end -print_hi('Tom') -#=> prints 'Hi, Tom' to STDOUT. -{% endhighlight %} - -Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk]. - -[jekyll-docs]: http://jekyllrb.com/docs/home -[jekyll-gh]: https://github.com/jekyll/jekyll -[jekyll-talk]: https://talk.jekyllrb.com/ diff --git a/_posts/graph/2016-12-26-test.markdown b/_posts/graph/2016-12-26-test.markdown new file mode 100644 index 000000000..9bbd03b2a --- /dev/null +++ b/_posts/graph/2016-12-26-test.markdown @@ -0,0 +1,10 @@ +--- +layout: post +title: "Test" +date: 2016-12-26 15:36:00 +0530 +categories: graph +--- + +This is just a test file to test post excerpt. + +Thank you diff --git a/_posts/search/2016-12-26-test.markdown b/_posts/search/2016-12-26-test.markdown new file mode 100644 index 000000000..33c152f4f --- /dev/null +++ b/_posts/search/2016-12-26-test.markdown @@ -0,0 +1,10 @@ +--- +layout: post +title: "Test" +date: 2016-12-26 15:36:00 +0530 +categories: search +--- + +This is just a test file to test post excerpt. + +Thank you diff --git a/pages/graph.html b/pages/graph.html new file mode 100644 index 000000000..45c4abb33 --- /dev/null +++ b/pages/graph.html @@ -0,0 +1,21 @@ +--- +layout: default +--- + +
Posts

+ + +
    + {% for post in site.categories.graph %} +
  • + +

    + {{ post.title | escape }} +

    +
  • + {% endfor %} +
+ + From 940ad5ad031a1e77151efc17f2f28a78cc21c776 Mon Sep 17 00:00:00 2001 From: smitbose Date: Tue, 27 Dec 2016 00:06:15 +0530 Subject: [PATCH 24/32] Made category pages --- _layouts/home.html | 12 +++++------ _layouts/post.html | 2 +- _posts/graph/2016-12-26-test.markdown | 10 --------- _posts/search/2016-12-26-test.markdown | 10 --------- _sass/minima/_layout.scss | 30 ++++++++++++++++++++++---- _sass/minima/tabs.scss | 4 ++-- pages/dp.html | 27 +++++++++++++++++++++++ pages/graph.html | 12 ++++++++--- pages/others.html | 27 +++++++++++++++++++++++ pages/searching.html | 27 +++++++++++++++++++++++ pages/sorting.html | 27 +++++++++++++++++++++++ pages/stackq.html | 27 +++++++++++++++++++++++ pages/trees.html | 27 +++++++++++++++++++++++ 13 files changed, 206 insertions(+), 36 deletions(-) delete mode 100644 _posts/graph/2016-12-26-test.markdown delete mode 100644 _posts/search/2016-12-26-test.markdown create mode 100644 pages/dp.html create mode 100644 pages/others.html create mode 100644 pages/searching.html create mode 100644 pages/sorting.html create mode 100644 pages/stackq.html create mode 100644 pages/trees.html diff --git a/_layouts/home.html b/_layouts/home.html index 8eca8c087..0de0324a7 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -6,19 +6,19 @@

Categories

-
+

Searching

Searching an element from a set of elements
-
+

Sorting

Sorting a set of elements in a particular order
-
+

Stack and Queue

Algorithms that require FIFO or LIFO processing
-
+

Trees

Segment trees, BITs and other algorithms for interval processing and searching
@@ -26,11 +26,11 @@

Trees

Graphs

Modelling real life problems as a set of vertices and links between them
-
+

Greedy and Dynamic Programming

Solving a bigger problem through solution of subproblems
-
+

Others

Any algorithm that doesn't come under the above categories
diff --git a/_layouts/post.html b/_layouts/post.html index 1d36c2828..ddce7bf45 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -7,7 +7,7 @@

{{ page.title | escape }}

- +
{{ content }}
diff --git a/_posts/graph/2016-12-26-test.markdown b/_posts/graph/2016-12-26-test.markdown deleted file mode 100644 index 9bbd03b2a..000000000 --- a/_posts/graph/2016-12-26-test.markdown +++ /dev/null @@ -1,10 +0,0 @@ ---- -layout: post -title: "Test" -date: 2016-12-26 15:36:00 +0530 -categories: graph ---- - -This is just a test file to test post excerpt. - -Thank you diff --git a/_posts/search/2016-12-26-test.markdown b/_posts/search/2016-12-26-test.markdown deleted file mode 100644 index 33c152f4f..000000000 --- a/_posts/search/2016-12-26-test.markdown +++ /dev/null @@ -1,10 +0,0 @@ ---- -layout: post -title: "Test" -date: 2016-12-26 15:36:00 +0530 -categories: search ---- - -This is just a test file to test post excerpt. - -Thank you diff --git a/_sass/minima/_layout.scss b/_sass/minima/_layout.scss index 407559fb3..852b4e742 100644 --- a/_sass/minima/_layout.scss +++ b/_sass/minima/_layout.scss @@ -180,11 +180,24 @@ > li { margin-bottom: $spacing-unit; } + h2 + { + margin: 15px 0px 0px 0px; + } } .post-meta { font-size: $small-font-size; color: $grey-color; + //margin-bottom: 5px; + float: left; +} + +.post-author { + font-size: $small-font-size; + color: $grey-color; + //margin-bottom: 5px; + float: right; } .post-link { @@ -192,20 +205,28 @@ font-size: 24px; } - +.post-excerpt { + float: left; +} /** * Posts */ +.post { + p { + margin: 0px; + } +} + .post-header { margin-bottom: $spacing-unit; } .post-title { - font-size: 42px; + font-size: 30px; letter-spacing: -1px; line-height: 1; - + font-weight: 800; @include media-query($on-laptop) { font-size: 36px; } @@ -213,7 +234,8 @@ .post-content { margin-bottom: $spacing-unit; - + float: left; + padding-top: 15px; h2 { font-size: 32px; diff --git a/_sass/minima/tabs.scss b/_sass/minima/tabs.scss index 1f86088df..19e12582f 100644 --- a/_sass/minima/tabs.scss +++ b/_sass/minima/tabs.scss @@ -2,13 +2,13 @@ div { .category { - border: 2px solid; + border: 0px solid; border-radius: 7px; float: left; text-align: left; width: -webkit-calc(80%); width: calc(80%); - background: #D3D3D3; + background: rgba(227,222,222,0.5); padding: 10px 5px 10px 20px; box-shadow: 5px 5px 2px #888888; margin: 5px 10% 5px 10%; diff --git a/pages/dp.html b/pages/dp.html new file mode 100644 index 000000000..da7fadaf4 --- /dev/null +++ b/pages/dp.html @@ -0,0 +1,27 @@ +--- +layout: default +--- + +
+ + + + +
    + {% for post in site.categories.dpgreedy %} +
  • +

    + {{ post.title | escape }} +

    + +
    +
    + {{ post.content | strip_html | truncatewords: 30 }} +
    +
    + Continue Reading... +
  • + {% endfor %} +
+ +
diff --git a/pages/graph.html b/pages/graph.html index 45c4abb33..99fdf9b74 100644 --- a/pages/graph.html +++ b/pages/graph.html @@ -2,18 +2,24 @@ layout: default --- -
-

Posts

+
    {% for post in site.categories.graph %}
  • -

    {{ post.title | escape }}

    + +
    +
    + {{ post.content | strip_html | truncatewords: 30 }} +
    +
    + Continue Reading...
  • {% endfor %}
diff --git a/pages/others.html b/pages/others.html new file mode 100644 index 000000000..6a1b26ea8 --- /dev/null +++ b/pages/others.html @@ -0,0 +1,27 @@ +--- +layout: default +--- + +
+ + + + +
    + {% for post in site.categories.others %} +
  • +

    + {{ post.title | escape }} +

    + +
    +
    + {{ post.content | strip_html | truncatewords: 30 }} +
    +
    + Continue Reading... +
  • + {% endfor %} +
+ +
diff --git a/pages/searching.html b/pages/searching.html new file mode 100644 index 000000000..d101bdd1e --- /dev/null +++ b/pages/searching.html @@ -0,0 +1,27 @@ +--- +layout: default +--- + +
+ + + + +
    + {% for post in site.categories.search %} +
  • +

    + {{ post.title | escape }} +

    + +
    +
    + {{ post.content | strip_html | truncatewords: 30 }} +
    +
    + Continue Reading... +
  • + {% endfor %} +
+ +
diff --git a/pages/sorting.html b/pages/sorting.html new file mode 100644 index 000000000..1010a068c --- /dev/null +++ b/pages/sorting.html @@ -0,0 +1,27 @@ +--- +layout: default +--- + +
+ + + + +
    + {% for post in site.categories.sort %} +
  • +

    + {{ post.title | escape }} +

    + +
    +
    + {{ post.content | strip_html | truncatewords: 30 }} +
    +
    + Continue Reading... +
  • + {% endfor %} +
+ +
diff --git a/pages/stackq.html b/pages/stackq.html new file mode 100644 index 000000000..e24008024 --- /dev/null +++ b/pages/stackq.html @@ -0,0 +1,27 @@ +--- +layout: default +--- + +
+ + + + +
    + {% for post in site.categories.stackq %} +
  • +

    + {{ post.title | escape }} +

    + +
    +
    + {{ post.content | strip_html | truncatewords: 30 }} +
    +
    + Continue Reading... +
  • + {% endfor %} +
+ +
diff --git a/pages/trees.html b/pages/trees.html new file mode 100644 index 000000000..ce31425dd --- /dev/null +++ b/pages/trees.html @@ -0,0 +1,27 @@ +--- +layout: default +--- + +
+ + + + +
    + {% for post in site.categories.tree %} +
  • +

    + {{ post.title | escape }} +

    + +
    +
    + {{ post.content | strip_html | truncatewords: 30 }} +
    +
    + Continue Reading... +
  • + {% endfor %} +
+ +
From 3301842738763ab0a50d7a06666304cedb77faef Mon Sep 17 00:00:00 2001 From: smitbose Date: Tue, 27 Dec 2016 00:12:27 +0530 Subject: [PATCH 25/32] Added gitkeep to folders --- _posts/dpgreedy/.gitkeep | 0 _posts/graph/.gitkeep | 0 _posts/others/.gitkeep | 0 _posts/search/.gitkeep | 0 _posts/sort/.gitkeep | 0 _posts/stackq/.gitkeep | 0 _posts/tree/.gitkeep | 0 7 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 _posts/dpgreedy/.gitkeep create mode 100644 _posts/graph/.gitkeep create mode 100644 _posts/others/.gitkeep create mode 100644 _posts/search/.gitkeep create mode 100644 _posts/sort/.gitkeep create mode 100644 _posts/stackq/.gitkeep create mode 100644 _posts/tree/.gitkeep diff --git a/_posts/dpgreedy/.gitkeep b/_posts/dpgreedy/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/_posts/graph/.gitkeep b/_posts/graph/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/_posts/others/.gitkeep b/_posts/others/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/_posts/search/.gitkeep b/_posts/search/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/_posts/sort/.gitkeep b/_posts/sort/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/_posts/stackq/.gitkeep b/_posts/stackq/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/_posts/tree/.gitkeep b/_posts/tree/.gitkeep new file mode 100644 index 000000000..e69de29bb From dcfc3b71173aab5dd0b50680e0004cfe47c8c4d8 Mon Sep 17 00:00:00 2001 From: smitbose Date: Tue, 27 Dec 2016 00:44:00 +0530 Subject: [PATCH 26/32] Debugs --- _layouts/home.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_layouts/home.html b/_layouts/home.html index 0de0324a7..23015d03c 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -5,8 +5,8 @@

Categories

- -
+ {% assign searchurl="/pages/searching.html" %} +

Searching

Searching an element from a set of elements
From 00728dcff01b31ca3ff56f42b9ad7fb35cee78fd Mon Sep 17 00:00:00 2001 From: smitbose Date: Tue, 27 Dec 2016 00:57:27 +0530 Subject: [PATCH 27/32] url linking debug --- _config.yml | 2 +- _layouts/home.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index 9c53ffef7..6e6db2ee7 100644 --- a/_config.yml +++ b/_config.yml @@ -17,7 +17,7 @@ title: Algorithms email: your-email@domain.com description: > # this means to ignore newlines until "baseurl:" A repository of some popular algorithms -baseurl: "" # the subpath of your site, e.g. /blog +baseurl: "/Algorithms" # the subpath of your site, e.g. /blog url: "" # the base hostname & protocol for your site, e.g. http://example.com twitter_username: github_username: codeIIEST diff --git a/_layouts/home.html b/_layouts/home.html index 23015d03c..7f5a537c8 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -6,7 +6,7 @@

Categories

{% assign searchurl="/pages/searching.html" %} -
+

Searching

Searching an element from a set of elements
From 23e864e311e00d31ee549831286ba8dce67af179 Mon Sep 17 00:00:00 2001 From: smitbose Date: Tue, 27 Dec 2016 01:08:58 +0530 Subject: [PATCH 28/32] Fixed urls --- _layouts/.home.html.swp | Bin 0 -> 12288 bytes _layouts/home.html | 20 +++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 _layouts/.home.html.swp diff --git a/_layouts/.home.html.swp b/_layouts/.home.html.swp new file mode 100644 index 0000000000000000000000000000000000000000..a60ba3eb9f08a9809f8c86729ece9ad1791eab7e GIT binary patch literal 12288 zcmeI2zi%8x6vrn>2nfWO9|aB4<51)R&KDC2Mdo}W1UWJyGRWaahh}fz-EO?Qv!0o~ z$TEhK|A8t61r2`!Ee!<)h<_mzRM1c$#CP^~?=0g)cCJ8{-sryCyV*Ch?|t5z9a)~} z%Ew!`=-TQPg|@8JCwuzSU)Nt$_nuSAnJQ0xxbg6ITDvc%hP~_A*x1x3x$AwF>3vgq z*Go*!tBKFEhd)a03IQSTCR!8~uD-EWFZEYDuh0w6fAlCb$rvFZ1cZPP5CTF# z2nYcoAOy}S0bgEFU&8mt8vkEwt{0A7o1bzK0zyCt2mv7=1cZPP5CTF#2nYcoAOy}K z0Uay#=95bO1BL(pw}1ct{j5^IL%%`ypLtP(0kC!&>u@m{Q%vA9P|?O*Cq5p z-$OC92`xiUK;J#1)K}0J^fq+=X{COI9CQa-hW@;$)Hl%A&<$t_`spdm31!eWv;;j4 z)qbBt?&7i#5CTF#2nYco@P85L_u_OiP(-sYgm%5yC*7V=B%f$cv0+!NcpBoEB2`7q z7X3^*G83ku_8d+$vcpWF^^>cEel*yIiFN&6H0bxxqi_R{qhY3<+vqf-_B&*XVU`Ye zH#(U?XKISo#PVok<=}u!n4+>7eNLt2l8boVrJh$K?KpHF9dm1&EZ@GfXl+MsU+FXlEJIJ?)g zYS0BW9@EI0e7-i?IF5PT4qVLVdY038eQ+5I)}>>-f13B(MyFTmF}q&f;p&s%9lCr7 zKj+5vTVrM!mnU1b%W-B{cbsh7)cDM_UW_N3wuLmatvmJ}U_4FV+;&<|4=`@I&CT0< z939Y4*4nKjpz0>9W7KG8aAUUpV4GPRD0Os~3FqpuL8xxGtEOk|*D2

Categories

- {% assign searchurl="/pages/searching.html" %} + {% assign searchurl="/pages/searching.html" %} + {% assign sorturl="/pages/sorting.html" %} + {% assign stackurl="/pages/stackq.html" %} + {% assign treeurl="/pages/trees.html" %} + {% assign graphurl="/pages/graph.html" %} + {% assign dpurl="/pages/dp.html" %} + {% assign otherurl="/pages/others.html" %}

Searching

Searching an element from a set of elements
-
+

Sorting

Sorting a set of elements in a particular order
-
+

Stack and Queue

Algorithms that require FIFO or LIFO processing
-
+

Trees

Segment trees, BITs and other algorithms for interval processing and searching
-
+

Graphs

Modelling real life problems as a set of vertices and links between them
-
+

Greedy and Dynamic Programming

Solving a bigger problem through solution of subproblems
-
+

Others

Any algorithm that doesn't come under the above categories
From 91063bd977da1befb6089e55d08fb4f31959575e Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Tue, 27 Dec 2016 09:17:54 +0530 Subject: [PATCH 29/32] Create SortsTutorial.md Created tutorial for Sorts under _posts/sort --- _posts/sort/SortsTutorial.md | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 _posts/sort/SortsTutorial.md diff --git a/_posts/sort/SortsTutorial.md b/_posts/sort/SortsTutorial.md new file mode 100644 index 000000000..4d990359d --- /dev/null +++ b/_posts/sort/SortsTutorial.md @@ -0,0 +1,63 @@ +## Sorting + +- [ ] Notes: + - Implement sorts & know best case/worst case, average complexity of each: + - no bubble sort - it's terrible - O(n^2), except when n <= 16 + - [ ] stability in sorting algorithms ("Is Quicksort stable?") + - [Sorting Algorithm Stability](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability) + - [Stability In Sorting Algorithms](http://stackoverflow.com/questions/1517793/stability-in-sorting-algorithms) + - [Stability In Sorting Algorithms](http://www.geeksforgeeks.org/stability-in-sorting-algorithms/) + - [Sorting Algorithms - Stability](http://homepages.math.uic.edu/~leon/cs-mcs401-s08/handouts/stability.pdf) + - [ ] Which algorithms can be used on linked lists? Which on arrays? Which on both? + - I wouldn't recommend sorting a linked list, but merge sort is doable. + - [Merge Sort For Linked List](http://www.geeksforgeeks.org/merge-sort-for-linked-list/) + +- For heapsort, see Heap data structure above. Heap sort is great, but not stable. + +- [ ] [Bubble Sort (video)](https://www.youtube.com/watch?v=P00xJgWzz2c&index=1&list=PL89B61F78B552C1AB) +- [ ] [Analyzing Bubble Sort (video)](https://www.youtube.com/watch?v=ni_zk257Nqo&index=7&list=PL89B61F78B552C1AB) +- [ ] [Insertion Sort, Merge Sort (video)](https://www.youtube.com/watch?v=Kg4bqzAqRBM&index=3&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb) +- [ ] [Insertion Sort (video)](https://www.youtube.com/watch?v=c4BRHC7kTaQ&index=2&list=PL89B61F78B552C1AB) +- [ ] [Merge Sort (video)](https://www.youtube.com/watch?v=GCae1WNvnZM&index=3&list=PL89B61F78B552C1AB) +- [ ] [Quicksort (video)](https://www.youtube.com/watch?v=y_G9BkAm6B8&index=4&list=PL89B61F78B552C1AB) +- [ ] [Selection Sort (video)](https://www.youtube.com/watch?v=6nDMgr0-Yyo&index=8&list=PL89B61F78B552C1AB) + +- [ ] Stanford lectures on sorting: + - [ ] [Lecture 15 | Programming Abstractions (video)](https://www.youtube.com/watch?v=ENp00xylP7c&index=15&list=PLFE6E58F856038C69) + - [ ] [Lecture 16 | Programming Abstractions (video)](https://www.youtube.com/watch?v=y4M9IVgrVKo&index=16&list=PLFE6E58F856038C69) + +- [ ] Shai Simonson, [Aduni.org](http://www.aduni.org/): + - [ ] [Algorithms - Sorting - Lecture 2 (video)](https://www.youtube.com/watch?v=odNJmw5TOEE&list=PLFDnELG9dpVxQCxuD-9BSy2E7BWY3t5Sm&index=2) + - [ ] [Algorithms - Sorting II - Lecture 3 (video)](https://www.youtube.com/watch?v=hj8YKFTFKEE&list=PLFDnELG9dpVxQCxuD-9BSy2E7BWY3t5Sm&index=3) + +- [ ] Steven Skiena lectures on sorting: + - [ ] [lecture begins at 26:46 (video)](https://youtu.be/ute-pmMkyuk?list=PLOtl7M3yp-DV69F32zdK7YJcNXpTunF2b&t=1600) + - [ ] [lecture begins at 27:40 (video)](https://www.youtube.com/watch?v=yLvp-pB8mak&index=8&list=PLOtl7M3yp-DV69F32zdK7YJcNXpTunF2b) + - [ ] [lecture begins at 35:00 (video)](https://www.youtube.com/watch?v=q7K9otnzlfE&index=9&list=PLOtl7M3yp-DV69F32zdK7YJcNXpTunF2b) + - [ ] [lecture begins at 23:50 (video)](https://www.youtube.com/watch?v=TvqIGu9Iupw&list=PLOtl7M3yp-DV69F32zdK7YJcNXpTunF2b&index=10) + +- [ ] UC Berkeley: + - [ ] [CS 61B Lecture 29: Sorting I (video)](https://www.youtube.com/watch?v=EiUvYS2DT6I&list=PL4BBB74C7D2A1049C&index=29) + - [ ] [CS 61B Lecture 30: Sorting II (video)](https://www.youtube.com/watch?v=2hTY3t80Qsk&list=PL4BBB74C7D2A1049C&index=30) + - [ ] [CS 61B Lecture 32: Sorting III (video)](https://www.youtube.com/watch?v=Y6LOLpxg6Dc&index=32&list=PL4BBB74C7D2A1049C) + - [ ] [CS 61B Lecture 33: Sorting V (video)](https://www.youtube.com/watch?v=qNMQ4ly43p4&index=33&list=PL4BBB74C7D2A1049C) + +- [ ] - Merge sort code: + - [ ] [Using output array](http://www.cs.yale.edu/homes/aspnes/classes/223/examples/sorting/mergesort.c) + - [ ] [In-place](https://github.com/jwasham/practice-cpp/blob/master/merge_sort/merge_sort.cc) +- [ ] - Quick sort code: + - [ ] [Implementation](http://www.cs.yale.edu/homes/aspnes/classes/223/examples/randomization/quick.c) + - [ ] [Implementation](https://github.com/jwasham/practice-c/blob/master/quick_sort/quick_sort.c) + +- [ ] Implement: + - [ ] Mergesort: O(n log n) average and worst case + - [ ] Quicksort O(n log n) average case + - Selection sort and insertion sort are both O(n^2) average and worst case + - For heapsort, see Heap data structure above. + +- [ ] For curiosity - not required: + - [ ] [Radix Sort](http://www.cs.yale.edu/homes/aspnes/classes/223/notes.html#radixSort) + - [ ] [Radix Sort (video)](https://www.youtube.com/watch?v=xhr26ia4k38) + - [ ] [Radix Sort, Counting Sort (linear time given constraints) (video)](https://www.youtube.com/watch?v=Nz1KZXbghj8&index=7&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb) + - [ ] [Randomization: Matrix Multiply, Quicksort, Freivalds' algorithm (video)](https://www.youtube.com/watch?v=cNB2lADK3_s&index=8&list=PLUl4u3cNGP6317WaSNfmCvGym2ucw3oGp) + - [ ] [Sorting in Linear Time (video)](https://www.youtube.com/watch?v=pOKy3RZbSws&list=PLUl4u3cNGP61hsJNdULdudlRL493b-XZf&index=14) From 3e93028d6f6529f12061812cc89c3fdb0d73366d Mon Sep 17 00:00:00 2001 From: Prateek Chanda Date: Tue, 27 Dec 2016 10:28:06 +0530 Subject: [PATCH 30/32] Update SortsTutorial.md --- _posts/sort/SortsTutorial.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/_posts/sort/SortsTutorial.md b/_posts/sort/SortsTutorial.md index 4d990359d..f9277cdea 100644 --- a/_posts/sort/SortsTutorial.md +++ b/_posts/sort/SortsTutorial.md @@ -1,5 +1,9 @@ +--- + ## Sorting +date: 2016-12-27 08:28:45 + - [ ] Notes: - Implement sorts & know best case/worst case, average complexity of each: - no bubble sort - it's terrible - O(n^2), except when n <= 16 @@ -61,3 +65,9 @@ - [ ] [Radix Sort, Counting Sort (linear time given constraints) (video)](https://www.youtube.com/watch?v=Nz1KZXbghj8&index=7&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb) - [ ] [Randomization: Matrix Multiply, Quicksort, Freivalds' algorithm (video)](https://www.youtube.com/watch?v=cNB2lADK3_s&index=8&list=PLUl4u3cNGP6317WaSNfmCvGym2ucw3oGp) - [ ] [Sorting in Linear Time (video)](https://www.youtube.com/watch?v=pOKy3RZbSws&list=PLUl4u3cNGP61hsJNdULdudlRL493b-XZf&index=14) + + +Author : Prateek Chanda + +--- + From c1f990f45263a37656cd8863e81ee3c2a90c5361 Mon Sep 17 00:00:00 2001 From: Soumit Bose Date: Sun, 12 Mar 2017 19:32:46 +0530 Subject: [PATCH 31/32] Revert "2016-12-27-SortsTutorial.md" --- _posts/sort/SortsTutorial.md | 73 ------------------------------------ 1 file changed, 73 deletions(-) delete mode 100644 _posts/sort/SortsTutorial.md diff --git a/_posts/sort/SortsTutorial.md b/_posts/sort/SortsTutorial.md deleted file mode 100644 index f9277cdea..000000000 --- a/_posts/sort/SortsTutorial.md +++ /dev/null @@ -1,73 +0,0 @@ ---- - -## Sorting - -date: 2016-12-27 08:28:45 - -- [ ] Notes: - - Implement sorts & know best case/worst case, average complexity of each: - - no bubble sort - it's terrible - O(n^2), except when n <= 16 - - [ ] stability in sorting algorithms ("Is Quicksort stable?") - - [Sorting Algorithm Stability](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability) - - [Stability In Sorting Algorithms](http://stackoverflow.com/questions/1517793/stability-in-sorting-algorithms) - - [Stability In Sorting Algorithms](http://www.geeksforgeeks.org/stability-in-sorting-algorithms/) - - [Sorting Algorithms - Stability](http://homepages.math.uic.edu/~leon/cs-mcs401-s08/handouts/stability.pdf) - - [ ] Which algorithms can be used on linked lists? Which on arrays? Which on both? - - I wouldn't recommend sorting a linked list, but merge sort is doable. - - [Merge Sort For Linked List](http://www.geeksforgeeks.org/merge-sort-for-linked-list/) - -- For heapsort, see Heap data structure above. Heap sort is great, but not stable. - -- [ ] [Bubble Sort (video)](https://www.youtube.com/watch?v=P00xJgWzz2c&index=1&list=PL89B61F78B552C1AB) -- [ ] [Analyzing Bubble Sort (video)](https://www.youtube.com/watch?v=ni_zk257Nqo&index=7&list=PL89B61F78B552C1AB) -- [ ] [Insertion Sort, Merge Sort (video)](https://www.youtube.com/watch?v=Kg4bqzAqRBM&index=3&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb) -- [ ] [Insertion Sort (video)](https://www.youtube.com/watch?v=c4BRHC7kTaQ&index=2&list=PL89B61F78B552C1AB) -- [ ] [Merge Sort (video)](https://www.youtube.com/watch?v=GCae1WNvnZM&index=3&list=PL89B61F78B552C1AB) -- [ ] [Quicksort (video)](https://www.youtube.com/watch?v=y_G9BkAm6B8&index=4&list=PL89B61F78B552C1AB) -- [ ] [Selection Sort (video)](https://www.youtube.com/watch?v=6nDMgr0-Yyo&index=8&list=PL89B61F78B552C1AB) - -- [ ] Stanford lectures on sorting: - - [ ] [Lecture 15 | Programming Abstractions (video)](https://www.youtube.com/watch?v=ENp00xylP7c&index=15&list=PLFE6E58F856038C69) - - [ ] [Lecture 16 | Programming Abstractions (video)](https://www.youtube.com/watch?v=y4M9IVgrVKo&index=16&list=PLFE6E58F856038C69) - -- [ ] Shai Simonson, [Aduni.org](http://www.aduni.org/): - - [ ] [Algorithms - Sorting - Lecture 2 (video)](https://www.youtube.com/watch?v=odNJmw5TOEE&list=PLFDnELG9dpVxQCxuD-9BSy2E7BWY3t5Sm&index=2) - - [ ] [Algorithms - Sorting II - Lecture 3 (video)](https://www.youtube.com/watch?v=hj8YKFTFKEE&list=PLFDnELG9dpVxQCxuD-9BSy2E7BWY3t5Sm&index=3) - -- [ ] Steven Skiena lectures on sorting: - - [ ] [lecture begins at 26:46 (video)](https://youtu.be/ute-pmMkyuk?list=PLOtl7M3yp-DV69F32zdK7YJcNXpTunF2b&t=1600) - - [ ] [lecture begins at 27:40 (video)](https://www.youtube.com/watch?v=yLvp-pB8mak&index=8&list=PLOtl7M3yp-DV69F32zdK7YJcNXpTunF2b) - - [ ] [lecture begins at 35:00 (video)](https://www.youtube.com/watch?v=q7K9otnzlfE&index=9&list=PLOtl7M3yp-DV69F32zdK7YJcNXpTunF2b) - - [ ] [lecture begins at 23:50 (video)](https://www.youtube.com/watch?v=TvqIGu9Iupw&list=PLOtl7M3yp-DV69F32zdK7YJcNXpTunF2b&index=10) - -- [ ] UC Berkeley: - - [ ] [CS 61B Lecture 29: Sorting I (video)](https://www.youtube.com/watch?v=EiUvYS2DT6I&list=PL4BBB74C7D2A1049C&index=29) - - [ ] [CS 61B Lecture 30: Sorting II (video)](https://www.youtube.com/watch?v=2hTY3t80Qsk&list=PL4BBB74C7D2A1049C&index=30) - - [ ] [CS 61B Lecture 32: Sorting III (video)](https://www.youtube.com/watch?v=Y6LOLpxg6Dc&index=32&list=PL4BBB74C7D2A1049C) - - [ ] [CS 61B Lecture 33: Sorting V (video)](https://www.youtube.com/watch?v=qNMQ4ly43p4&index=33&list=PL4BBB74C7D2A1049C) - -- [ ] - Merge sort code: - - [ ] [Using output array](http://www.cs.yale.edu/homes/aspnes/classes/223/examples/sorting/mergesort.c) - - [ ] [In-place](https://github.com/jwasham/practice-cpp/blob/master/merge_sort/merge_sort.cc) -- [ ] - Quick sort code: - - [ ] [Implementation](http://www.cs.yale.edu/homes/aspnes/classes/223/examples/randomization/quick.c) - - [ ] [Implementation](https://github.com/jwasham/practice-c/blob/master/quick_sort/quick_sort.c) - -- [ ] Implement: - - [ ] Mergesort: O(n log n) average and worst case - - [ ] Quicksort O(n log n) average case - - Selection sort and insertion sort are both O(n^2) average and worst case - - For heapsort, see Heap data structure above. - -- [ ] For curiosity - not required: - - [ ] [Radix Sort](http://www.cs.yale.edu/homes/aspnes/classes/223/notes.html#radixSort) - - [ ] [Radix Sort (video)](https://www.youtube.com/watch?v=xhr26ia4k38) - - [ ] [Radix Sort, Counting Sort (linear time given constraints) (video)](https://www.youtube.com/watch?v=Nz1KZXbghj8&index=7&list=PLUl4u3cNGP61Oq3tWYp6V_F-5jb5L2iHb) - - [ ] [Randomization: Matrix Multiply, Quicksort, Freivalds' algorithm (video)](https://www.youtube.com/watch?v=cNB2lADK3_s&index=8&list=PLUl4u3cNGP6317WaSNfmCvGym2ucw3oGp) - - [ ] [Sorting in Linear Time (video)](https://www.youtube.com/watch?v=pOKy3RZbSws&list=PLUl4u3cNGP61hsJNdULdudlRL493b-XZf&index=14) - - -Author : Prateek Chanda - ---- - From 266d9069916ce276f7b3f96ab06d09aa36ca7dc2 Mon Sep 17 00:00:00 2001 From: smitbose Date: Sat, 10 Jun 2017 16:27:22 +0530 Subject: [PATCH 32/32] Updated Gemfile.lock --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f1c082640..5274988a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,7 +50,7 @@ DEPENDENCIES minima (~> 2.0) RUBY VERSION - ruby 2.3.3p222 + ruby 2.4.1p111 BUNDLED WITH - 1.13.6 + 1.15.1