Giter Site home page Giter Site logo

Comments (10)

cclauss avatar cclauss commented on May 18, 2024 1

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.

from javascript.

cclauss avatar cclauss commented on May 18, 2024 1

Our test cases are when length < 2 so...
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.

from javascript.

sahilbansal17 avatar sahilbansal17 commented on May 18, 2024

@cclauss It seems that both the implementations are exactly the same algorithmically.

from javascript.

poyea avatar poyea commented on May 18, 2024

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/.

from javascript.

cclauss avatar cclauss commented on May 18, 2024

;-) Are lines 10-13 needed?

Update: Proven with doctests in #171

from javascript.

poyea avatar poyea commented on May 18, 2024

;-) Are lines 10-13 needed?

If the loop starts with i=1 and compares this[i-1] with this[i] then it is, but no for the current code.

from javascript.

cclauss avatar cclauss commented on May 18, 2024

Does the loop ever execute at all?

from javascript.

poyea avatar poyea commented on May 18, 2024

Yes. It's kind of an extension for the Array object. That's why we can use it directly.
https://js.do/code/438412

from javascript.

stale avatar stale commented on May 18, 2024

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.

from javascript.

stale avatar stale commented on May 18, 2024

Please reopen this issue once you commit the changes requested or make improvements on the code. Thank you for your contributions.

from javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.