This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigInteger; | |
class KaratsubaMulti{ | |
public static BigInteger compute(String x,String y) | |
{ | |
int n = 0; | |
int n1 = x.length(); | |
int n2 = y.length(); | |
if(n1>=n2)n=n2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.ArrayList; | |
public class Inversions { | |
static long total = 0; | |
public static int[] inversions(int a[],int s,int e) | |
{ | |
if(a.length <= 1) | |
return a; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Unimodal { | |
public static void unimodal(int a[],int l,int h) | |
{ | |
int mid = (l+h)/2; | |
if(a[mid] < a[mid+1]) | |
{ | |
if(a[mid+1] > a[mid+2]) | |
{ | |
System.out.println("The max element is : "+a[mid+1]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IndexEEle { | |
static int a[] = {-3,-1,0,1,4,6,7,8}; | |
static int flag = 0; | |
public static void find(int l,int h) | |
{ | |
int mid=(l+h)/2; | |
if (mid<a[mid]) | |
find(l,mid-1); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*package whatever //do not write package name here */ | |
import java.lang.Math; | |
public class segmentTree | |
{ | |
static int a[] = {1,2,3,4,5}; | |
static int tree[]; //segment tree that you will construct | |
public static void buildTree(int sb,int se) | |
{ | |
int numOfLeaves=a.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Scanner; | |
import java.io.File; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Random; | |
/* | |
* Karger's algorithm to compute the minimum cut of a connected graph. | |
* Takes as input an undirected connected graph and computes a cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. How are binary and text modes for files different ? | |
2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.Math; | |
import java.util.*; | |
class SegmentTree | |
{ | |
static int n; | |
static ArrayList<Integer> ar; | |
static int t[]; | |
static int[] map; | |
SegmentTree(int n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.lang.Math; | |
public class MinHeap { | |
ArrayList<Integer> ar = new ArrayList<>(); | |
int size = 0; | |
void delete(int pos) | |
{ | |
ar.set(pos,ar.get(ar.size()-1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.lang.Math; | |
public class MaxHeap { | |
ArrayList<Integer> ar = new ArrayList<>(); | |
int size = 0; | |
void delete(int pos) | |
{ | |
ar.set(pos,ar.get(ar.size()-1)); |
OlderNewer