You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rationalize the two different implementations of heap sort #164
We have two different implementations of heap sort. Can we build a benchmark to prove which one is faster or better than the other? Benchmark against small datasets, large datasets, and empty datasets. It is OK to keep both if they have different strengths and weaknesses. If there is a clear winner, let's delete the other one.
Can we build a benchmark to prove which one is faster or better than the other?
It would be cool to have a benchmark because then we would have proof that they are the same and have the same performance for multiple datasets. Hint: I doubt it.
Such a benchmark could be extended to do side-by-side performance tests of all 19 of our sort algorithms. Benchmarks are cool and they have the power to push our contributors to optimize.
Also, there's something more we can do. At least BogoSort has an isSorted function and a shuffle function. We can make use of these two functions to build our test sets for the whole sort/.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
sahilbansal17 commentedon May 11, 2020
@cclauss It seems that both the implementations are exactly the same algorithmically.
cclauss commentedon May 11, 2020
It would be cool to have a benchmark because then we would have proof that they are the same and have the same performance for multiple datasets. Hint: I doubt it.
Such a benchmark could be extended to do side-by-side performance tests of all 19 of our sort algorithms. Benchmarks are cool and they have the power to push our contributors to optimize.
poyea commentedon May 12, 2020
Also, there's something more we can do. At least BogoSort has an
isSortedfunction and ashufflefunction. We can make use of these two functions to build our test sets for the wholesort/.cclauss commentedon May 12, 2020
;-) Are lines 10-13 needed?
Update: Proven with doctests in #171
poyea commentedon May 12, 2020
If the loop starts with
i=1and comparesthis[i-1]withthis[i]then it is, but no for the current code.cclauss commentedon May 12, 2020
Does the loop ever execute at all?
poyea commentedon May 12, 2020
Yes. It's kind of an extension for the Array object. That's why we can use it directly.
https://js.do/code/438412
cclauss commentedon May 12, 2020
Our test cases are when
length < 2so...document.write([].isSorted()); // --> true
document.write([1].isSorted()); // --> true
Now comment out lines 10-13 and run again.
You will get the exact same results because the loop never runs.
Lines 10-13 can be deleted.
BogoSort.js: Simplify Array.isSorted() and add doctests
Fetching last changes (#1)
stale commentedon Feb 13, 2021
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Feb 21, 2021
Please reopen this issue once you commit the changes requested or make improvements on the code. Thank you for your contributions.
BogoSort.js: Simplify Array.isSorted() and add doctests
BogoSort.js: Simplify Array.isSorted() and add doctests
BogoSort.js: Simplify Array.isSorted() and add doctests
BogoSort.js: Simplify Array.isSorted() and add doctests
BogoSort.js: Simplify Array.isSorted() and add doctests
BogoSort.js: Simplify Array.isSorted() and add doctests