Templates For DSA9
Templates For DSA9
public:
void mergeSort(int arr[], int l, int r)
{
if (l < r)
{
// Same as (l+r)/2, but avoids overflow for
// large l and h
int m = l+(r-l)/2;
merge(arr, l, m, r);
}
}
};
-----------------------------------
Quick Sort::
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
-------------------------------------------------------------------------
Disjoint Set using rank and path compression-- T.c Vlog(V). Log(v) for finding
absolute parent for all V vertices.
class Solution {
public:
vector<int> parent;
vector<int> rank;
int find(int u ) {
if (u == parent[u])
return parent[u];