This file contains 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> | |
#define MAX 100 | |
#define initial 1 | |
#define waiting 2 | |
#define visited 3 | |
int n; |
This file contains 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> | |
#define MAX_DEGREE 5 | |
#define MAX_NUM_VERTICES 20 | |
struct vertices_s { | |
int visited; | |
int deg; | |
int adj[MAX_DEGREE]; /* < 0 if incoming edge */ |
This file contains 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> | |
typedef struct node | |
{ | |
struct node *next; | |
int vertex; | |
}node; | |
node *G[20]; |
This file contains 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> | |
void DFS(int); | |
int G[10][10],visited[10],n; //n is no of vertices and graph is sorted in array G[10][10] | |
void main() | |
{ | |
int i,j; | |
printf("Enter number of vertices:"); | |
This file contains 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 MAX 200 | |
int n,adj[MAX][MAX]; | |
int front = -1,rear = -1,queue[MAX]; | |
void main() { | |
int i,j = 0,k; | |
int topsort[MAX],indeg[MAX]; | |
create_graph(); | |
printf(“The adjacency matrix is:\n”); | |
display(); |
This file contains 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> | |
void compute(int n) | |
{ | |
if(n > 0) | |
comp(0, n, 0, 0); | |
return; | |
} | |
void comp(int p, int n, int o, int c) |
This file contains 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
boolean compute(int A[],int len,int sum) | |
{ | |
int l, h; | |
//Assuming A is already sorted | |
for (int i = 0; i < len- 2; i++) { | |
l = i + 1; | |
h= len - 1; | |
while (l < h) { |
This file contains 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
public class Solution { | |
public int fact(int n) | |
{ | |
return (n <= 1)? 1 :n * fact(n-1); | |
} | |
public int findRank(String A) | |
{ int ans=0; | |
This file contains 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
void unsort(int* arr) { | |
int l= arr.length; | |
int end = -1, start = -1, i=0, j= l-1; | |
do{ | |
if(start == -1) | |
{ | |
for(int x= i+1;x<l;x++) | |
{ | |
if(a[x]<a[i]) | |
{start = i;break;} |
NewerOlder