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 () 
Selftest implementations, 1st test.  
static void  test2 () 
Selfimplementations, 2nd test.  
int  main () 
Main function.  
It is a very powerful data structure that 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) get_max(i),get_min(i) : returns the maximum and minimum Below is the classbased approach which uses the heuristic of path compression. Using path compression in findSet(i),we are able to get to the representative of i in O(1) time.
int main  (  void  ) 
Main function.
< number of items
< object of class disjoint sets

static 
Selftest implementations, 1st test.
< number of items
< object of class disjoint sets

static 
Selfimplementations, 2nd test.
< number of items
< object of class disjoint sets