Skip to content

Instantly share code, notes, and snippets.

View quickgrid's full-sized avatar

Asif Ahmed quickgrid

View GitHub Profile
@quickgrid
quickgrid / in.txt
Created August 24, 2016 23:00
Sample input file for flex compiled program.
/*
This is a comment
*/
{Another}
// And another
/* Another */
@quickgrid
quickgrid / FlexTokenInsertionSymbolTable.l
Last active August 24, 2016 21:58
Break down the statement into lexme's using regular expression then insert the tokens on the symbol table.
%{
#include<bits/stdc++.h>
using namespace std;
#define CHAIN_LENGTH 53
#define M 128
struct symbol_info{
@quickgrid
quickgrid / CompilerSymbolTable.cpp
Last active August 24, 2016 20:35
This is a simple compiler symbol table with name and class type entries. Inserts new strings through hashing, search for an element in appropriate chain using hashing, delete and update given element properties and show the chains.
/**
* Author: Asif Ahmed
* Description: Compiler Symbol table creation.
* Site: https://quickgrid.blogspot.com
* If there is any problem first try the solution below:
* 1. Change char pointers inside to fixed size array.
* 2. In the insert function use strcpy() function instead of ->
*/
#include<bits/stdc++.h>
@quickgrid
quickgrid / UVA 10583 - Ubiquitous Religions solution c++.cpp
Created July 23, 2016 06:32
UVA 10583 - Ubiquitous Religions solution c++ union by rank and path compression
/**
* Author: Asif Ahmed
* Site: https://quickgrid.wordpress.com
* Problem: UVA 10583 - Ubiquitous Religions
* Technique: Disjoint-Set Forest Union by Rank
* and Path Compression using Structure.
*/
#include<stdio.h>
#include<string.h>
@quickgrid
quickgrid / UVA 10608 - Friends solution c++.cpp
Last active August 26, 2018 10:06
UVA 10608 - Friends solution c++ Disjoint-Set Forest Union by Rank and Path Compression using Structure.
/**
* Author: Asif Ahmed
* Site: https://quickgrid.wordpress.com
* Problem: UVA 10608 - Friends
* Technique: Disjoint-Set Forest Union by Rank
* and Path Compression using Structure.
*/
#include<stdio.h>
#include<string.h>
@quickgrid
quickgrid / UVA 459 - Graph Connectivity Solution C++.cpp
Created July 23, 2016 05:52
Solution to UVA 459 - Graph Connectivity in C++ using union by rank and path compression.
/**
* Author: Asif Ahmed
* Site: https://quickgrid.wordpress.com
* Problem: UVA 10583 - Ubiquitous Religions
* Technique: Disjoint-Set Forest Union by Rank
* and Path Compression using Structure.
*/
#include<stdio.h>
#include<string.h>
@quickgrid
quickgrid / 352 - The Seasonal War.cpp
Last active June 4, 2016 17:06
Solution to UVA 352 - The Seasonal War. Given a graph or, a 2D array find out the number of connected components. Assuming 1's are the nodes. Run depth first search in the given graph to get connected components.
/**
* Author: Asif Ahmed
* Site: http://quickgrid.blogspot.com
* Description: Find out number of connected components.
*/
#include<bits/stdc++.h>
using namespace std;
#define M 26
@quickgrid
quickgrid / 118 - Mutant Flatworld Explorers.cpp
Created June 4, 2016 16:51
UVA solution to 118 - Mutant Flatworld Explorers. Write a code so a robot learns from mistakes of past robots. The robot doesn't fall off from the location the past robots fell off from.
/**
* Author: Asif Ahmed
* Site: http://quickgrid.blogspot.com
* Description: 118 - Mutant Flatworld Explorers.cpp
* Write a code so a robot learns from mistakes of past robots.
* The robot doesn't fall off from the location the past robots fell off from.
*/
#include<bits/stdc++.h>
@quickgrid
quickgrid / UVA 280 - vertex(vector of list).cpp
Created May 30, 2016 16:30
UVA 280 vertex graph problem solution using C++ OOP Graph representation. Find connected components count and print unreachable nodes.
/**
* Author: Asif Ahmed
* Site: http://quickgrid.blogspot.com
* Solution: vector of list oop graph representation and operation.
* Task: Input directed graph, find out connected component count,
* print out unreachable nodes.
* Note: Input node is from 1 to 100. So, here it is 0 to 99 to
* keep it simple.
*/
@quickgrid
quickgrid / UVA 280 - vertex(vector of vector).cpp
Created May 30, 2016 16:29
UVA 280 vertex graph problem solution using C++ OOP Graph representation. Find connected components count and print unreachable nodes.
/**
* Author: Asif Ahmed
* Site: http://quickgrid.blogspot.com
* Solution: vector of vector oop graph representation and operation.
* Task: Input directed graph, find out connected component count,
* print out unreachable nodes.
* Note: Input node is from 1 to 100. So, here it is 0 to 99 to
* keep it simple.
*/