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
import java.io.*; | |
import java.util.*; | |
import java.util.LinkedList; | |
// This class represents an undirected graph using adjacency list | |
public class Graph | |
{ | |
private int V; // No. of vertices | |
private LinkedList<Integer> adj[]; //Adjacency List | |
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<iostream> | |
#include<queue> | |
#include<stack> | |
using namespace std; | |
class Graph{ | |
int nodes; //No of nodes in the graph | |
int **A; //A is the adjacency matrix => the graph datastructure | |
public: | |
Graph(int nodes){ |
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
/** | |
Handle multiple socket connections with select and fd_set on Linux | |
Raj Abishek <[email protected]> | |
*/ | |
#include <stdio.h> | |
#include <string.h> //strlen | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <unistd.h> //close |
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<string.h> | |
#define N strlen(g) | |
char t[28],cs[28],g[]="1011"; | |
int a,e,c; | |
void xorfunction(){ | |
for(c = 1;c < N; c++) | |
cs[c] = (( cs[c] == g[c])?'0':'1'); |
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
// A C / C++ program for Dijkstra's single source shortest path algorithm. | |
// The program is for adjacency matrix representation of the graph | |
#include <stdio.h> | |
#include <limits.h> | |
// Number of vertices in the graph | |
#define V 9 | |
// A utility function to find the vertex with minimum distance value, from |
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> | |
struct node | |
{ | |
unsigned dist[20]; | |
unsigned from[20]; | |
}rt[10]; | |
int main() | |
{ | |
int costmat[20][20]; | |
int nodes,i,j,k,count=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
#include<stdio.h> | |
int main() { | |
int k=0,output[10],d=0,t=0,ins[5],i,avail[5],allocated[10][5],need[10][5],MAX[10][5],pno,P[10],j,rz, count=0; | |
printf("\n Enter the number of resources : "); | |
scanf("%d", &rz); | |
printf("\n enter the max instances of each resources\n"); | |
for (i=0;i<rz;i++) { | |
avail[i]=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
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#include <unistd.h> | |
#include <semaphore.h> | |
sem_t semaphore; | |
void threadfunc() { |
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<pthread.h> | |
#include<stdlib.h> | |
void* thread_function(void* arg){ | |
int id = (int)arg; | |
switch(id){ | |
case 1: sleep(1); break; | |
case 2: sleep(2); break; |
NewerOlder