Hacker News new | ask | show | jobs
by wnesensohn 3684 days ago
The visualizer is really nice, the examples could use some work though.

Selection Sort, for example, makes the algorithm look extremely (impossibly) good at first glance - O(n) - because it's not showing the majority of the steps.

Instead of

    for (var j = i + 1; j < D.length; j++) {
        if (D[j] < D[minJ]) {
            tracer._select(j);
            minJ = j;
            tracer._deselect(j);
        }
    }
it has to be

    for (var j = i + 1; j < D.length; j++) {
        tracer._select(j);
        if (D[j] < D[minJ]) {
            minJ = j;
        }
        tracer._deselect(j);
    }
Bubble Sort has the same problem, as do Quicksort and Mergesort.

Normally I wouldn't mind, but these examples are intended for beginners, and it might give them a false sense of time complexity for these basic algorithms.

1 comments

Raise an issue in case the author isn't reading here. https://github.com/parkjs814/AlgorithmVisualizer/issues