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
package com.shuffle; | |
import static com.sorting.insert.SortUtils.exchange; | |
import java.util.Random; | |
public class Shuffle { | |
public int[] shuffle(int[] input) { | |
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
package com.shuffle; | |
import static com.sorting.insert.SortUtils.arrayToString; | |
import static org.junit.Assert.assertFalse; | |
import org.junit.Test; | |
public class ShuffleTest { | |
@Test |
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
package com.sorting.insert; | |
import static com.sorting.insert.SortUtils.arrayToString; | |
import static org.junit.Assert.*; | |
import org.junit.Test; | |
public class InsertionSortTest { | |
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
package com.sorting.insert; | |
public class SortUtils { | |
public static boolean less (Comparable a, Comparable b){ | |
return a.compareTo(b)<0; | |
} | |
public static boolean less (int a, int b){ |
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
package com.sorting.merge; | |
import static com.sorting.insert.SortUtils.arrayToString; | |
import static org.junit.Assert.*; | |
import org.junit.Test; | |
import com.sorting.insert.InsertionSort; | |
public class MergeSortTest { |
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
package basics.sorting.quick; | |
import static basics.sorting.utils.SortUtils.exchange; | |
import static basics.sorting.utils.SortUtils.less; | |
import basics.shuffle.KnuthShuffle; | |
public class QuickSortBasic { | |
public void sort (int[] input){ | |
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
package basics.sorting.quick; | |
import static basics.shuffle.KnuthShuffle.shuffle; | |
import static basics.sorting.utils.SortUtils.exchange; | |
import static basics.sorting.utils.SortUtils.less; | |
public class QuickSort3Way { | |
public void sort (int[] input){ |
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
package com.sorting.quick._3way; | |
import static com.sorting.insert.SortUtils.arrayToString; | |
import org.junit.Test; | |
public class QuickSort3WayTest { | |
@Test | |
public void testQuickSort() { |
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
package basics.sorting.quick; | |
import static basics.shuffle.KnuthShuffle.shuffle; | |
import static basics.sorting.utils.SortUtils.exchange; | |
import static basics.sorting.utils.SortUtils.less; | |
public class QuickSortDualPivot { | |
public void sort (int[] input){ | |
//input=shuffle(input); |
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
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one or more | |
contributor license agreements. See the NOTICE file distributed with | |
this work for additional information regarding copyright ownership. | |
The ASF licenses this file to You under the Apache License, Version 2.0 | |
(the "License"); you may not use this file except in compliance with | |
the License. You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 |