Giter Club home page Giter Club logo

Comments (5)

lujiaying avatar lujiaying commented on May 28, 2024

From the attached picture, the error may come from L46.

Imaging when k=2, compare(k/3, k) would be compare(0, 2). Since the 0th element in keys is null, it would raise NullPointException.

from dsa-java.

ddalama avatar ddalama commented on May 28, 2024

Thanks for the feedback. In L46, I changed compare(k/3, k) to compare((k+1)/3, k), but I got new errors.

I also changed L38 to else if((k-1)%3==0 || k%3==0) { and changed L43 to else if((k+1)%3==0) { //if node is the left node

Also, is the problem/error only in swim() method? I can rewrite it if this is the case.

I have attached my errors and new code below:

Screenshot 2020-09-23 at 4 30 10 AM

prog2

from dsa-java.

ddalama avatar ddalama commented on May 28, 2024

Also, is there a way to do the benchmarking part of the assignment if these errors don't go away?

Thanks.

from dsa-java.

jdchoi77 avatar jdchoi77 commented on May 28, 2024

@ddalama the NPE is caused because you do not check the key index being 0, which returns null. Make sure it will not access the 0'th key that is null in your case.

from dsa-java.

jdchoi77 avatar jdchoi77 commented on May 28, 2024

@ddalama please do not post your code as an issue; if you need to please put the link to the code in your private repository. Closing this issue.

from dsa-java.

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.