Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.

#include <cassert>
#include <iostream>
#include <vector>
Classes  
class  dsu 
Disjoint sets union data structure, class based representation. More...  
Functions  
static void  test1 () 
Selfimplementations, 1st test.  
static void  test2 () 
Selfimplementations, 2nd test.  
int  main () 
Main function.  
dsu : It is a very powerful data structure which keeps track of different clusters(sets) of elements, these sets are disjoint(doesnot have a common element). Disjoint sets uses cases : for finding connected components in a graph, used in Kruskal's algorithm for finding Minimum Spanning tree. Operations that can be performed: 1) UnionSet(i,j): add(element i and j to the set) 2) findSet(i): returns the representative of the set to which i belogngs to. 3) getParents(i): prints the parent of i and so on and so forth. Below is the classbased approach which uses the heuristic of unionranks. Using unionrank in findSet(i),we are able to get to the representative of i in slightly delayed O(logN) time but it allows us to keep tracks of the parent of i.
int main  (  void  ) 
Main function.

static 
Selfimplementations, 1st test.
< number of elements
< object of class disjoint sets
< performs union operation on 1 and 2

static 
Selfimplementations, 2nd test.
< number of elements
< object of class disjoint sets
performs union operation on 1 and 2
keeping track of the changes using parent pointers
makes sure algorithm works fine