private int[] mergeArrays(int[] left, int[] right) {
        int totalLength = left.length+right.length;
        int[] newArray = new int[totalLength];
        int cursor1 = 0, cursor2 = 0;
        for (int i = 0; i < totalLength; i++) {
            int leftElement = left.length > cursor1 ? left[cursor1] : Integer.MAX_VALUE;
            int rightElement = right.length > cursor2 ? right[cursor2] : Integer.MAX_VALUE;
            if (leftElement < rightElement) {
                newArray[i] = leftElement;
                cursor1++;
            } else {
                newArray[i] = rightElement;
                cursor2++;
            }

            oneOperation();
        }
        return newArray;
    }