Skip to content

Instantly share code, notes, and snippets.

View rajabishek's full-sized avatar

Raj Abishek rajabishek

View GitHub Profile
@rajabishek
rajabishek / food_menu.xml
Last active July 6, 2023 15:31
Simple Food Menu XML File
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<desc>Two of our famous Belgian Waffles with plenty of real maple syrup</desc>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
@rajabishek
rajabishek / greedy-coloring.java
Created April 12, 2016 03:35
Greedy Coloring
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
@rajabishek
rajabishek / shortest.c
Created November 1, 2015 19:59
Dijkstra's algorithm alternate
#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){
@rajabishek
rajabishek / multiclient.c
Created November 1, 2015 19:13
Multiple Client Handling TCP Server
/**
Handle multiple socket connections with select and fd_set on Linux
Raj Abishek <rajabishek@hotmail.com>
*/
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h>
#include <errno.h>
#include <unistd.h> //close
@rajabishek
rajabishek / crc.c
Created November 1, 2015 17:32
Cyclic Redundancy Check
#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');
@rajabishek
rajabishek / dijkstras.c
Created November 1, 2015 17:31
Dijkstra's Algorithm
// 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
@rajabishek
rajabishek / distance.c
Created November 1, 2015 17:30
Distance Vector Routing
#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;
@rajabishek
rajabishek / bankers.c
Created May 8, 2015 14:51
Banker's Algorithm - Finding the safety sequence
#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;
@rajabishek
rajabishek / sample.c
Created March 19, 2015 17:51
Sem_wait and Sem_post
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <semaphore.h>
sem_t semaphore;
void threadfunc() {
@rajabishek
rajabishek / thread.c
Created March 19, 2015 17:47
Creating Threads - Passing integer parameters
#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;