Skip to content

Instantly share code, notes, and snippets.

View saisumit's full-sized avatar

SUMIT VOHRA saisumit

View GitHub Profile
#include <bits/stdc++.h>
using namespace std;
/*
Note: I haven't tested the code completely but logic is correct and you can manipulate the code to correct minor bugs
under Creative Common license
*/
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define FOR(i, n) for (int i = 0; i < n; i++)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
unsigned int message = 0 ;
unsigned int POLYNOMIAL = 0 ;
unsigned int rem = 0 ;
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
// IMPLEMENT PARITY CHECK
// odd parity error
int main ( )
{
string s ;
/*
Distance Vector Routing in this program is implemented using Bellman Ford Algorithm:-
*/
#include<stdio.h>
struct node
{
unsigned dist[20];
unsigned from[20];
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < n; i++)
// IMPLEMENT HAMMING CODE ERROR CORRRECTING
int main ( )
{
string s ;
#include <bits/stdc++.h>
using namespace std;
// IMPLEMENT BYTE STUFFING AND CHARACTER STUFFING
// Bit STUFFING ADD ONE ZERO AFTER EVERY 5 CONSECTIVE ONES
/*
Byte stuffing can solvethe problem by reserving a third character to mark occurrences of special characters
in the data.Use reserved characters to indicate the start and end of a frame. For instance, use the two-character
sequence DLE STX (Data-Link Escape, Start of TeXt) to signal the beginning of a frame, and thesequence
DLE ETX (End of TeXt) to flag the frame's end.Problem: What happens if the two-character sequence DLE
bool check( path , vertex , posn )
{
for i = 1 to posn
if path[ i ] == vertex // checking if this vertex has already occured in our path
then return false // if yes then return false
// 4->2->1
void segregateEvenOdd(struct node *head_ref)
{
struct node* it = head_ref;
struct node* prevofe = NULL ;
struct node* evenh = NULL ;
struct node* prev = NULL ; // Initially prev is null
struct node* temp;
@saisumit
saisumit / C.cpp
Last active August 6, 2016 21:28
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define FOR(i, n) for (int i = 0; i < n; i++)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define fill(ar, val) memset(ar, val, sizeof(ar))
#define PI 3.1415926535897932385
#define uint64 unsigned long long