On Monday, 31 October 2016 at 20:25:18 UTC, Hefferman wrote:
            for (uint k = 1; k < n; k++) {
                if (a[k-1] > a[k]) {
                    T tmp = a[k];
                    a[k] = a[k+1];
                    a[k+1] = tmp;
                    sorted = false;
                }
            }
            n--;
        } while (!sorted);
    }
}
[/code]

It gives a Range Violation upon executing, but I guess it's part of the algorithm....

The value of n is array length, so k reaches (n - 1), therefore k+1 gives you n which is out of bounds.

Reply via email to