Question
Can someone explain to me in comments of a trace of what this code does line for line.
Explanation / Answer
public class MergeSort { public static void sort(T[] table) { if (table.length > 1) { int halfSize = table.length / 2; T[] leftTable = (T[]) new Comparable[halfSize]; T[] rightTable = (T[]) new Comparable[table.length - halfSize]; System.arraycopy(table, 0, leftTable, 0, halfSize); System.arraycopy(table, halfSize, rightTable, 0, table.length - halfSize); sort(leftTable); sort(rightTable); merge(table, leftTable, rightTable); } } private static void merge(T[] outputSequence, T[] leftTable, T[] rightTable) { int i = 0, j = 0, k = 0; while (i