This file contains hidden or 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 com.djitz.sort; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
/** | |
* Quick sort algorithm (simple) | |
* based on pseudo code on Wikipedia "Quick Sort" aricle | |
* |
This file contains hidden or 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.Arrays; | |
import java.util.Random; | |
/** | |
* Merge sort algorithm (Top down) | |
* based on pseudocode at Wikipedia "Merge sort" article | |
* @see <a href="http://en.wikipedia.org/wiki/Merge_sort"/> | |
* @author djitz | |
* | |
*/ |
This file contains hidden or 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
//Array | |
A = {1...n} | |
//Sort algorithm | |
for i = 2 to n | |
j = i | |
while j > 1 | |
if A[j] < A[j - 1] | |
swap A[j] and A[j - 1] | |
j = j - 1 |
This file contains hidden or 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.Arrays; | |
import java.util.Random; | |
/** | |
* Insertion Sort Algorithm. | |
* @author djitz | |
* | |
*/ | |
public class InsertionSort { |