Skip to content

My attempt to remove the bottlenecks in my dual-threaded mergesort.

Notifications You must be signed in to change notification settings

SBrazzCode/sortingPlayground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

Introduction

This is my attempt to remove the bottlenecks in my dual-threaded MergeSort.

Spoiler I went further and made it scale to the number of processors on the calling system.

The sortingPlayground started as an assignment for CPRG-311. It is an eclipse project that runs on JRE 1.8+ We needed to write implementations of 6 sorting algorithms:

  1. Bubble Sort
  2. Insertion Sort
  3. Selection Sort
  4. MergeSort
  5. Quick Sort
  6. A sorting algorithm of our choice (I chose HeapSort)

I went further an tried to run my mergesort with two threads. This attempt ran slower than my single-threaded implementation. To create a better solution I had to discover cache missing. Now, my MergeSort is cache friendly and creates a thread for each processor on the system. The MergeSort algorithm is the most documented algorithm, for it is the only algorithm that could be valuable to external parties.

How To Use (Short)

To use the sorting algorithms, download Sort.java :: found in sortingPlayground/sortCollection/src/utilities. Sort.java is a standalone file; the majority of the project demonstrates how you could use these sorting algorithms.

How To Use (Long)

Dependencies: Eclipse, commons-io-2.8.0.jar

  1. Clone the Repository with eclipse.
  2. Add external jars
  3. (Optional) Create a jar
  4. Run i.e. Run with these arguments –fpolyfor1.txt –Ta –Sm

if polyfor1.txt is not in the same directory as the .jar, or it is not directly under the sortCollection project directory, you must provide the absolute path after -f.

Arguments

-f Provide the file with shapes to be sorted

-t Provide the property of the shape to be used in comparisons: A for baseArea, H for height, V for Volume

-s Provide the sorting implementation to be used: M for Merge, I for insertion, S for Selection, B for Bubble, Q for Quick and Z for Heap

Releases

No releases published

Packages

No packages published

Languages