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 MergeSorter | |
{ | |
private static int[] a, b; | |
public static void sort(int[] c) | |
{ | |
a=c; | |
int n=a.length; | |
b=new int[(n+1)/2]; | |
mergesort(0, n-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
void shellsort(int *a, int n) | |
{ | |
int h, i, j, k; | |
for (h = n; h /= 2;) | |
{ | |
for (i = h; i < n; i++) | |
{ | |
k = a[i]; | |
for (j = i; j >= h && k < a[j - h]; j -= h) { | |
a[j] = a[j - h]; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
void Multiply(int n, double** a, double** b, double** c) | |
{ | |
int bi=0; | |
int bj=0; | |
int bk=0; | |
int i=0; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#define MAXTHRDS 124 | |
typedef struct | |
{ | |
double *my_x; | |
double *my_y; |
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
#include <pthread.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <omp.h> | |
#include <sys/time.h> | |
#define N 1000 | |
int A[N][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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <float.h> | |
#include <mpi.h> | |
int n, p; | |
int main(int argc, char **argv) | |
{ | |
int myn, myrank; | |
double *a, *b, *c, *allB, start, sum, *allC, sumdiag; |
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
int BinarySearch(int *array, int n, int key) | |
{ | |
register int low = 0, high = n-1, mid; | |
while(low <= high) | |
{ | |
mid = low + ((high-low)/2); | |
if(array[mid] < key) | |
low = mid + 1; | |
else if(array[mid] > key) | |
high = 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 static int binarySearch(int[] nums, int key) | |
{ | |
int hi = nums.length - 1; | |
int lo = 0; | |
int mid | |
while(hi >= lo) | |
{ | |
mid = lo + ((hi - lo) / 2); | |
if(nums[mid] > key) | |
hi = 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
int fibSearch(int a[], int n, int x) | |
{ | |
int inf=0, pos, k; | |
static int kk= -1, nn=-1, fib[]={0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141}; | |
if(nn!=n) | |
{ | |
k=0; | |
while(fib[k]<n) | |
k++; |
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
class String | |
#Capitalize the beginning of ever word in a string. | |
def word_capitalize | |
self.gsub(/\b\w/){$&.upcase} | |
end | |
#Check for balanced parantheses | |
def para_check? | |
para=Array.new |