Skip to content

Instantly share code, notes, and snippets.

View arunma's full-sized avatar

Argon arunma

  • Singapore
View GitHub Profile
@arunma
arunma / MergeSortTest.java
Created May 31, 2013 12:20
Merge Sort Test
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 {
@arunma
arunma / MergeSort
Created May 31, 2013 12:19
Merge Sort
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);
@arunma
arunma / SortUtils.java
Created May 31, 2013 12:19
Sort Utils
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){
@arunma
arunma / InsertionSortTest.java
Created May 31, 2013 12:19
Insertion Sort Test
package com.sorting.insert;
import static com.sorting.insert.SortUtils.arrayToString;
import static org.junit.Assert.*;
import org.junit.Test;
public class InsertionSortTest {
@arunma
arunma / InsertionSort.java
Created May 31, 2013 12:18
Insertion Sort
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--){
@arunma
arunma / ShuffleTest.java
Created May 31, 2013 12:18
Knuth Shuffle Test
package com.shuffle;
import static com.sorting.insert.SortUtils.arrayToString;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
public class ShuffleTest {
@Test
@arunma
arunma / KnuthShuffle.java
Created May 31, 2013 12:17
Knuth Shuffle
package com.shuffle;
import static com.sorting.insert.SortUtils.exchange;
import java.util.Random;
public class Shuffle {
public int[] shuffle(int[] input) {
@arunma
arunma / DeepEquals.java
Created November 4, 2012 17:08
Arrays.deepEquals vs Arrays.equals
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.Arrays;
import org.testng.annotations.Test;
public class DeepEquals {
@arunma
arunma / Constants.java
Created October 17, 2012 07:38
Selenium Utils - support Constants
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";
@arunma
arunma / InfixToValueParenthesis.groovy
Created October 16, 2012 17:30
Infix expression evaluator with parentheses - multiple digits
/**
* 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