Skip to content

Instantly share code, notes, and snippets.

View shahrajat's full-sized avatar
💭
// TODO

Rajat Shah shahrajat

💭
// TODO
View GitHub Profile
@shahrajat
shahrajat / LRUCache.cpp
Last active December 26, 2015 21:59
LRU Cache Implementation LeetCode
class LRUCache{
private:
map<int,list<pair<int, int>>::iterator> keyToListItr; //key to list node*
list<pair<int,int>> clist;
int capacity;
public:
LRUCache(int capacity) {
this->capacity = capacity;
}
@shahrajat
shahrajat / DFS_BFS.cpp
Created November 8, 2015 07:03
Implement DFS and BFS for an undirected graph and unweighted graph.
/*
Name : Rajat Shah
Task : Implement DFS and BFS for an undirected graph and unweighted graph.
Notes: Contains hard-coded map of the city to be searched, uses just string reprentation of city(nodes)!
Instructions to compile and run:
To compile:
g++ BFSDFS.cpp
@shahrajat
shahrajat / NQueen.cpp
Created November 8, 2015 07:01
Solving N Queen using Genetic Algorithm.
/*
Author : @Rajat Shah
Task: Solving N Queen using Genetic Algorithm.
Comments: Hard coded for 8x8 chess, can be modified for arbitrary size.
*/
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
@shahrajat
shahrajat / 8TilePuzzle.cpp
Created November 8, 2015 06:48
Solving 8-tile puzzle using A* algorithm
/*
Author : @Rajat Shah
Written: 2013 as a part of Assignment for Aritifial Intelligence course taken at VNIT, Nagpur
Task: Solving 8-tile puzzle using A* algorithm with Manhattan Distance as Heuristic.
Comments: Configurations can be done from the macro declarations
0 can be considered as the blank position
Sample Solvable Initial State:
1 | 4 | 2
3 | 5 | 0