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 void main(String[] args) { | |
String ciphertext = "HSPAASLJPWOLYALEAJVBSKILHWYVISLTIBAUVAPMPAPZHZOPMAJPWOLY"; | |
for(int shiftKey = 0; shiftKey < 26; shiftKey++) | |
{ | |
String plainText = ""; | |
for (int i=0; i<ciphertext.length(); i++) | |
{ |
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
static int modinv(int a, int b) | |
{ | |
int a0 = a; | |
int b0 = b; | |
int t0 = 0; | |
int t = 1; | |
int q = (int)Math.floor( a0 / b0 ); | |
int r = a0 - (q * b0); |
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 StraightInsertionSort { | |
/*insertionsort | |
Description: Performs a insertion sort on a given list | |
Parameters: | |
int[] list: array of integers to be sorted | |
Pre: Initialized array | |
Post: Sorted array | |
Returns: Sorted array |
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 ShellSort { | |
/*shellsort | |
Description: Performs a shell sort on a given list | |
Parameters: | |
int[] list: array of integers to be sorted | |
int[] increments: array of bucket sizes | |
Pre: Initialized array | |
Post: Sorted array | |
Returns: Sorted array |
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 HeapSort { | |
/*heapsort | |
Description: Performs a heap sort on a given list | |
Parameters: | |
int[] list: array of integers to be sorted | |
Pre: Initialized array | |
Post: Sorted array | |
Returns: Sorted array |
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.io.BufferedInputStream; | |
import java.io.BufferedOutputStream; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.util.Enumeration; | |
import java.util.zip.ZipEntry; | |
import java.util.zip.ZipFile; |
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 DataNode { | |
/*DataNode Constructor | |
Description: Called when an object is instantiated | |
Parameters: | |
Object Elem : object stored as data in this class | |
Pre: None | |
Post: Initialized element |
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
private static int gfib(int f0, int f1, int n) | |
{ | |
switch( n ) | |
{ | |
case 0: | |
return f0; | |
case 1: | |
return f1; | |
default: | |
return gfib(f0,f1, n-1 ) + gfib(f0, f1, 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
private static int gcd(int x, int y){ | |
if( y <= x & (x%y) == 0) | |
return y; | |
else if( x < y) | |
return gcd(y,x); | |
else | |
return gcd(y, x % y); | |
} | |
private static int iterativegcd(int x, int 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
private static int binarySearch( int[ ] a, int toFind, int low, int high ) | |
{ | |
if( low > high ) | |
return -1; | |
int mid = ( low + high ) / 2; | |
if( a[ mid ] > toFind ) | |
return binarySearch( a, toFind, mid + 1, high ); | |
else if( a[ mid ] < toFind ) |