public int findMinimumSwapsUtil(int input[], Map<Integer, Integer> pair, Map<Integer, Integer> index, int current) {
        if (current == input.length) {
            return 0;
        }

        int v1 = input[current];
        int v2 = input[current + 1];
        int pv2 = pair.get(v1);

        if(pv2 == v2) {
            return findMinimumSwapsUtil(input, pair, index, current + 2);
        } else {
            int idx1 = index.get(v1);
            int idx2 = index.get(v2);

            int idx3 = index.get(pair.get(v1));
            int idx4 = index.get(pair.get(v2));

            swap(index, input, idx2, idx3);
            int val1 = findMinimumSwapsUtil(input, pair, index, current + 2);
            swap(index, input, idx2, idx3);

            swap(index, input, idx1, idx4);
            int val2 = findMinimumSwapsUtil(input, pair, index, current + 2);
            swap(index, input, idx1, idx4);

            return 1 + Math.min(val1, val2);
        }
    }
Date 12/30/2015
@author Tushar Roy

Given input array with every element in array having its pair element. How many minimum swaps needs to be
done so that all pair elements are adjacent to each other.

Time complexity is O(2^n)

http://www.geeksforgeeks.org/minimum-number-of-swaps-required-for-arranging-pairs-adjacent-to-each-other/
src/com/interview/recursion/SetPairTogether.java