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.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 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.sorting.merge; | |
| import static com.sorting.insert.SortUtils.less; | |
| public class MergeSort { | |
| public Comparable[] sort(Comparable[] items) { | |
| sort (items,new Comparable[items.length], 0, items.length-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
| 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 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.sorting.insert; | |
| import static com.sorting.insert.SortUtils.arrayToString; | |
| import static org.junit.Assert.*; | |
| import org.junit.Test; | |
| public class InsertionSortTest { | |
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.sorting.insert; | |
| import static com.sorting.insert.SortUtils.*; | |
| public class InsertionSort { | |
| public Comparable[] sort(Comparable[] items) { | |
| for (int i=0;i<items.length;i++){ | |
| for (int j=i;j>0;j--){ |
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.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 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.shuffle; | |
| import static com.sorting.insert.SortUtils.exchange; | |
| import java.util.Random; | |
| public class Shuffle { | |
| public int[] shuffle(int[] input) { | |
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 static org.testng.Assert.assertFalse; | |
| import static org.testng.Assert.assertTrue; | |
| import java.util.Arrays; | |
| import org.testng.annotations.Test; | |
| public class DeepEquals { |
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
| public interface Constants { | |
| public static final String BANNER = "****************************************************************************************"; | |
| public static final String VALIDATION_REPORT = "************************************** VALIDATION REPORT **********************************"; | |
| public static final String ENABLED="enabled"; | |
| public static final String DISABLED="disabled"; | |
| public static final String VISIBLE="visible"; | |
| public static final String INVISIBLE="hidden"; | |
| public static final String REPORTS_FOLDER="reports"; |
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
| /** | |
| * Only basic arithmetic operators are supported. However, could easily be | |
| * extended to support any binary operators | |
| * | |
| * This program is not an infix to postfix converter. However, this program does the following | |
| * | |
| * 1) Evaluates a parenthesized or non-parenthesized infix expression and drives it to a final value | |
| * 2) Supports parentheses | |
| * 3) Supports multiple digits as operands | |
| * 4) Empty space allowed |