Search:

Type: Posts; User: Norm

Search: Search took 0.10 seconds.

  1. Thread: Memoization

    by Norm
    Replies
    17
    Views
    1,058

    [SOLVED] Re: Memoization

    bd should be defined outside of the fibonnaci() method so it is only created one time, not every time the method is called.
  2. Thread: Memoization

    by Norm
    Replies
    17
    Views
    1,058

    [SOLVED] Re: Memoization

    If you are only using the -1 as a flag, you could create one instance of BigInteger with that value and use it in all the places where the code is creating new instances with the value of -1.

    See...
  3. Thread: Memoization

    by Norm
    Replies
    17
    Views
    1,058

    [SOLVED] Re: Memoization

    The snippet of code I posted says that this expression doesn't work as you expect:

    mapping.get(n).equals(-1)
  4. Thread: Memoization

    by Norm
    Replies
    17
    Views
    1,058

    [SOLVED] Re: Memoization

    Why is it coded to return a -1? If the code I posted worked, then the method would return a -1 instead of a good number.
  5. Thread: Memoization

    by Norm
    Replies
    17
    Views
    1,058

    [SOLVED] Re: Memoization

    I'm not sure the posted code works. Add some debugging code like this:

    //if not in memory
    System.out.println("test for -1 "+ mapping.get(n)); //<<<<<<<<<...
  6. Thread: Memoization

    by Norm
    Replies
    17
    Views
    1,058

    [SOLVED] Re: Memoization

    Can you post your solution so everyone can see what the problem was and how you solved it?
  7. Thread: Memoization

    by Norm
    Replies
    17
    Views
    1,058

    [SOLVED] Re: Memoization

    Is that statement executed? What is the value of bg when it is executed?
    Try debugging the code by adding some println statements to see what statements are executing and to see the values of the...
  8. Thread: Memoization

    by Norm
    Replies
    17
    Views
    1,058

    [SOLVED] Re: Memoization

    Where does the code add the other places (besides 0 and 1)?
    Does it always add -1 in the other places?
Results 1 to 8 of 8