Code Monkey home page Code Monkey logo

Comments (2)

dgrcode avatar dgrcode commented on May 22, 2024

Hi!

I just ran the code I wrote for the actual assignment and it passed all the tests, included the two you mentioned.

For random_32_1000 the output in the repo is [16, 9] and your output is [19, 9].
For random_48_10000 the output in the repo is [26, 12] and your output is [30, 12].

In both cases the min matches but the max doesn't. The fact that the rest of the tests pass with your algorithm makes me think the counting is done correctly, so I'm guessing the issue is related with the logic of the algorithm.

The fact that in both cases your max output is bigger would also make sense if there was a logic issue with your implementation.

I'd recommend trying to look for possible edge cases that your algorithm wouldn't support at the moment. Have a look at the slides, one file named algo2-greedy-huffman4-typed.pdf. There they talk about "Huffman’s Algorithm: A More Complex Example". In that case the input makes the tree grow in a way that is slightly different than most of the time, and that way of growing makes the tree be smaller, and therefore the max would be smaller too.

How are you keeping track of the node that should be merged next?

That's just a guess and it could be something else, but it's definitely worth checking.

Let me know how it goes!

from stanford-algs.

dgrcode avatar dgrcode commented on May 22, 2024

I'm closing this issue, but please feel free to reopen if you consider there's an error in the test cases

from stanford-algs.

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.