Skip to content

Instantly share code, notes, and snippets.

View shubham100795's full-sized avatar

shubham100795

View GitHub Profile
@shubham100795
shubham100795 / topview.cpp
Last active February 22, 2017 14:13
Top View of BST using STL library
#include<iostream>
#include<cstdlib>
#include<queue>
#include<map>
using namespace std;
struct node{
int data;
struct node *left;
@shubham100795
shubham100795 / verticalview.cpp
Last active February 22, 2017 14:12
Vertical View of a BST
#include<iostream>
#include<map>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
struct node{
int data;
struct node *left;
@shubham100795
shubham100795 / nodesatdistk.cpp
Created February 20, 2017 17:34
print nodes at a distance 'k' from leaf nodes
#include<iostream>
#include<set>
#include<cstdlib>
using namespace std;
struct node{
int data;
struct node *left;
struct node *right;
};
@shubham100795
shubham100795 / bottomview.cpp
Created February 22, 2017 14:11
print the bottom view , vertical view and top view of the BST
#include<iostream>
#include<cstdlib>
#include<queue>
#include<map>
using namespace std;
struct node{
int data;
struct node *left;
struct node *right;
@shubham100795
shubham100795 / romanstointeger.cpp
Created February 26, 2017 05:43
Roman Numerals to Integer
#include<iostream>
#include<string>
using namespace std;
int getvalue(char r)
{
if (r == 'I')
return 1;
if (r == 'V')
return 5;
@shubham100795
shubham100795 / leftview.cpp
Created February 27, 2017 19:02
left view of a binary tree
#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
struct node{
int data;
struct node *left;
struct node *right;
};
@shubham100795
shubham100795 / findceilfloor.cpp
Created March 2, 2017 14:13
Find ceil and floor of a key in BST
#include<iostream>
#include<cstdlib>
using namespace std;
struct node{
int data;
struct node *left;
struct node *right;
};
@shubham100795
shubham100795 / maxbtw2nodes.c
Created March 5, 2017 18:47
Maximum element between two nodes of a BST
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
struct node{
int data;
struct node *left;
struct node *right;
};
struct node *newnode(int x)
@shubham100795
shubham100795 / BFS.cpp
Created March 7, 2017 20:24
BFS in a graph along with shortest distance and path from the starting vertex to any other vertex
#include<iostream>
#include<queue>
#include<climits>
#define initial 0
#define waiting 1
#define visited 2
#define NIL -1
using namespace std;
int adj[10][10];
@shubham100795
shubham100795 / stronglyconnected.cpp
Last active July 30, 2017 09:12
find strongly connected components in a directed graph using kosaraju's algorithm
#include<iostream>
#include<stack>
#define initial 0
#define visited 1
#define finished 2
using namespace std;
int adj[10][10];
int rev_adj[10][10];
int state[10];