Skip to content

Instantly share code, notes, and snippets.

View devteampentagon's full-sized avatar

Team Pentagon devteampentagon

View GitHub Profile
package kumar116;
public class Mergesort <T extends Comparable<T>> {
public void sort(T[] data) {
mergesort(data, 0, data.length - 1);
}
private void mergesort(T[] data, int low, int high) {
if (low < high) {
package kumar116;
/* @author Soumya Kumar
* (mathbits.com/MathBits/Java/arrays/InsertionSort.htm)
*
* @summary
* The insertion sort is fast and efficient with smaller arrays. It loses it's efficiency over large amounts of data.
*/
public class InsertionSort<T extends Comparable<T>> {
@devteampentagon
devteampentagon / Number Sorting upto 10 to the power 6 digits.cpp
Created February 27, 2017 17:59
Number Sorting upto 10 to the power 6 digits
// Author: Emrul Chowdhury
#include <bits/stdc++.h>
#define LL long long int
using namespace std;
map <LL, LL> mp;
vector <string> v[2000005];
vector <LL> v1;
@devteampentagon
devteampentagon / Big Integer Fibonacci.cpp
Created February 27, 2017 17:53
Big Integer Fibonacci
#include <bits/stdc++.h>
#define SIZE 100000
using namespace std;
string BigIntFibo (string a,string b)
{
if (a.size()<b.size())
{
string temp=a;
@devteampentagon
devteampentagon / Computing the square root of a given number using Newton method.java
Created February 27, 2017 17:50
Computing the square root of a given number using Newton method
import java.util.Scanner ;
public class sdz {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(squaroot(2,16,0.05));
}
static double squaroot(int start, double number , double precision){
@devteampentagon
devteampentagon / Lowest Common Ancestors in a Binary Tree [Method - 1].cpp
Created January 30, 2017 20:20
Lowest Common Ancestors in a Binary Tree [Method - 1]
#include <bits/stdc++.h>
#define MEM(a,b) memset((a),(b),sizeof(a))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MIN3(a,b,c) MIN(MIN(a,b),c)
#define MIN4(a,b,c,d) MIN(MIN(MIN(a,b),c),d)
#define In freopen("In.txt", "r", stdin);
#define Out freopen("out.txt", "w", stdout);
@devteampentagon
devteampentagon / Armstrong Number.cpp
Created January 29, 2017 21:00
Armstrong Number
#include <bits/stdc++.h>
#define MEM(a,b) memset((a),(b),sizeof(a))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MIN3(a,b,c) MIN(MIN(a,b),c)
#define MIN4(a,b,c,d) MIN(MIN(MIN(a,b),c),d)
#define In freopen("In.txt", "r", stdin);
#define Out freopen("out.txt", "w", stdout);
@devteampentagon
devteampentagon / Heap Sort [Min Heap].cpp
Created January 29, 2017 20:42
Heap Sort [Min Heap]
#include <bits/stdc++.h>
#define MEM(a,b) memset((a),(b),sizeof(a))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MIN3(a,b,c) MIN(MIN(a,b),c)
#define MIN4(a,b,c,d) MIN(MIN(MIN(a,b),c),d)
#define In freopen("In.txt", "r", stdin);
#define Out freopen("out.txt", "w", stdout);
@devteampentagon
devteampentagon / Heap Sort [Max Heap].cpp
Created January 29, 2017 20:40
Heap Sort [Max Heap]
#include <bits/stdc++.h>
#define MEM(a,b) memset((a),(b),sizeof(a))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MIN3(a,b,c) MIN(MIN(a,b),c)
#define MIN4(a,b,c,d) MIN(MIN(MIN(a,b),c),d)
#define In freopen("In.txt", "r", stdin);
#define Out freopen("out.txt", "w", stdout);
@devteampentagon
devteampentagon / Permutations of a string.cpp
Created January 26, 2017 04:27
Permutations of a string
#include <bits/stdc++.h>
#define MEM(a,b) memset((a),(b),sizeof(a))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MIN3(a,b,c) MIN(MIN(a,b),c)
#define MIN4(a,b,c,d) MIN(MIN(MIN(a,b),c),d)
#define In freopen("In.txt", "r", stdin);
#define Out freopen("out.txt", "w", stdout);