Welcome to Basic Building Blocks

This entire repository is a giant Java testing ground for me. All the classes here are experimental and are merely for fun. There are several packages with random classes ranging from cryptography to sorting to file handling.

Notes on the following packages

Currently crypto package is not implemented, though I have some future plans for it. I also seem to have a few packages such as the .files package, which have been poorly implemented. My bad...

Cryptography

I decided to implement a Hashed-Unhashed random mapping of ASCII characters to act as a simple crypto, since I wished to try implementing my own secure protocol. Miserably failed. Well, the idea was good enough, so of my interest is piqued again, i'll attempt to complete what I started.

Files

I don't exactly remember why, but I wanted to implement an asynchronous file sharing algorithm over TCP protocol. Java has a nice API for files, multithreading and socket programming, so, why not? Well it seems my poor understanding of java.nio and java.net packages led to the project's failure. Text files are transferred as fast as lightning, even at sizes of a few gigabytes, but looses indentation. That is to say nothing of files such as Word, PDF, or even simple JPegs.

Note to self : Fix this mess up sometime.

Random

I wanted to create a Random number generator whose outputs were so erratic, it might simulate humans. Succeeded upto a point, although if carefully traced back, it's values can still be predicted. Not a complete failure, but not a perfect shining example of success either.

TrueRandom random = new TrueRandom();
random.nextInt();

Serialization

When i first found the GSON library I thought there would be no use to it other than web server communication. How wrong can one man be... Oh well, at least I have rectified my mistake. This works splendidly to store and retrieve extremely large objects to and from a file storage. I expected nothing less from a Google library.

Sort

My pride and joy as a Computer Science student is to develop faster, better and more efficient algorithms/programs. Succeeded in a way of speaking, since my ParallelMergeSort beats even Arrays.sort() on datasets larger equal or larger than 2 Million data items and is available from Java 6 onwards. However, Arrays.parallelSort(), available in Java 8 onwards, beats this class even at 100 Million data items, which is the practical limit of available RAM for this sorting algorithm.

My one regret : Space complexity of ParallelMergeSort is O(n).

My attempt to improve upon this class of mine, led me to develop PartitionParallelMergeSort, based on the Java 8 Fork/Join Framework. However, maybe due to my own inability, or some reason, it's performance is highly lacking, and it cant tolerate data sets of even 10 Million items.

Note to self : Try and reduce Space Complexity of ParallelMergeSort, and if possible, improve performance of PartitionParallelMergeSort as well.

Finally, ParallelQuickSort comes to save me. This is my fastest, and most efficient sorting algorithm I've ever implemented. Can sort up any number of data items, in a time that is slightly faster than even the Java 8 Arrays.parallelSort(). An acheivement, since Arrays.parallelSort() crashes at data sets of over 150 Million.

int data[] = new int[n]; //Fill with random data
ParallelMergeSort.sort(data);
//Or
PartitionParallalMergeSort.sort(data);
//Or
ParallelQuickSort.sort(data);

Tests

Test classes for above packages. Contains the all important ResultWriter class which is my implementation of a helper class to write the results of tests into some file. Multithreaded and based on ExecutorService framework, so dont forget to closeWriter();

ResultWriter writer = new ResultWriter("Filename");
writer.write("data");
writer.closeWriter();

Future

Well, for now this is all that this bundle of misfit classes can do. I plan to improve them, as and when I have some time. Also, ideas will always pop into my head, and this repo will come to my aid once again.