This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //insertion sort | |
| #include<stdio.h> | |
| int main() | |
| { | |
| int arr[5]={5,4,3,2,1}; | |
| int i,j,chose; | |
| int n = sizeof(arr)/sizeof(int); | |
| for(i=1;i<n;i++) | |
| { | |
| chose = arr[i]; // chose the ith card |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| int main() | |
| { | |
| int arr[5]={5,4,3,2,1}; | |
| int n = sizeof(arr)/sizeof(int); | |
| int i,j,t; | |
| for(i=1;i<n;i++) | |
| { | |
| for(j=0;j<n-i;j++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| #define true 1 | |
| #define false 0 | |
| #define size 8 | |
| //function declarations | |
| void printsolution(int sol[][size]); | |
| int solvetour(int x,int y, int nextmove, int sol[][size],int a[],int b[]); | |
| int issafe(int x, int y, int sol[][size]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // using dynamic programming | |
| #include <stdio.h> | |
| #define MAX 8 | |
| int get_length(int a[]) | |
| { | |
| int i,j; | |
| int length = 0; | |
| int dp[10]={1}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // calculates binomial coefficient using dynamic programming | |
| #include <stdio.h> | |
| #define MAX 100 | |
| int cache[MAX+1][MAX+1]; | |
| int ncr(int n,int r) | |
| { | |
| if(cache[n][r]==-1) | |
| cache[n][r] = ncr(n-1,r)+ncr(n-1,r-1); | |
| return cache[n][r]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| #include<stdlib.h> | |
| int t[8] = {-1}; | |
| int sol = 1; | |
| void printsol() | |
| { | |
| int i,j; | |
| char crossboard[8][8]; | |
| for(i=0;i<8;i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| #include<stdlib.h> | |
| char in[]= {'d','b','e','a','f','c','g'}; | |
| char pre[]={'a','b','d','e','c','f','g'}; | |
| int size = sizeof(in); | |
| int pos = 0; | |
| typedef struct node{ | |
| char value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| int main() | |
| { | |
| int arr[] = {1, 3, 5, 8, 9, 1,1,2, 6, 7, 6, 8}; | |
| int n = sizeof(arr)/sizeof(int); | |
| int i,j,step=0,jump=0,choice,max,val; | |
| for(i=0;i<n;) | |
| { | |
| choice = arr[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| int main() | |
| { | |
| int input[] = {1, 3, 5 ,8 ,9 ,2 ,6, 7, 6, 8, 9}; | |
| int n = sizeof(input)/sizeof(int); | |
| int dp[n]; | |
| int i,j,min,value,x; | |
| dp[n-1] = 0; | |
| for(i=n-2;i>=0;i--) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define HASH_TABLE_SIZE 100 | |
| #define HASH_TABLE_DELETE_ELEMENT_CHECK_FOR_ERRORS(t, n) | |
| if (hash_table_delete_element(t, n) == 0) | |
| hash_table_fatal_error(0, n) |