Implimentation of Algorithms and Datastructures Index: Contest templates My template Java My template C++ Data Structures Array Dynamic array implementation Find pairs (a,b) such thart n= a+b Find mode of array Cyclic traversal of array Variable Sized Array Merge two sorted arrays into one (two pointer) Linked list Linked List Implementation (Under development!) Stack Stack made from array Two stacks in one array Stack linked list implementation Infix to postfix expression conversion Queue Queue impementation using array Queue impementation using Linked list Graph Union Find Disjoint Set Trees Binary search tree Trie (Prefix tree).cpp Heap Priority queue (binary heap) Segment tree Accumulated sum Segment tree range sum and update Miscellaneous Searching Algorithems Binary search (Recursive) Binary search (Iterative) Sorting Algorithms Heap sort Bubble sort Insertion sort Selection Sort Qucik sort (Recursive) Merge sort (recursive) Combinatorial search Catalan numbers O(n^2) Generating all permutations Generating power set (Bitmasking) Generating power set (Backtracking) Permutations with repetition Constraint Satisfaction Problem 8 Puzzle Problem 8 Queen Problem Knight Tour Problem Knight's Tour Problem (optimized) Maze solving Maze all possible path count Dynamic programming 0-1 Knapsack Coin change problem Minimum coin change problem Longest Common Subsequence Maximum sub array sum(Kadane's algorithm) Number Theory Prime Numbers Prime number generation - sieve of eratosthenes Composite number generation Prime Factorization Prime Check - simple algo Divisors Generate divisors of (1 to n) Number of divisors (from prime factors) Number Bases Binary to decimal (Nested multiplication) Octal to decimal (Nested multiplication) Decimal to binary converter Binary to decimal converter Miscellaneous Euler's totient (phi) GCD and LCM Extended GCD random numbers Josephus Problem Summing digits (Iterative) Summing digits (recursive) Generating Fibonacci sequence Big Mod - Modular exponentiation Finding square root (Binary search) Greedy Algorithm Task schedulling Fractional knapsack Graph algorithms Breath first search Depth first search Single source shortest distance (undirected) Topological sort(BFS) Topological sort(DFS) Find Articulation nodes and edges SCC Kosaraju's algorithm Pattern Printing Print star String Algorithms Pattern Matching Rabin karp KMP Algorithm Find string occurrance cstring Find string occurrance string objects