Search:

Type: Posts; User: keepStriving

Search: Search took 0.13 seconds.

  1. Replies
    17
    Views
    1,071

    [SOLVED] Re: Memoization

    true, would be better for efficiency.
  2. Replies
    17
    Views
    1,071

    [SOLVED] Re: Memoization

    Finally got it, got my answer too. Thank you for bearing with me.


    public static BigInteger fibonnaci(int n){
    BigInteger bd = new BigInteger("-1");
    //if n==0||n==1
    if(n==0||n==1){...
  3. Replies
    17
    Views
    1,071

    [SOLVED] Re: Memoization

    Changed it to this still get problems, though I understand its not processing "if in memory" right, I'll get there eventually.


    //if in memory, if greater than -1, meaning has a value other than...
  4. Replies
    17
    Views
    1,071

    [SOLVED] Re: Memoization

    "-1" was meant to symbolise that certain value fibonacci value has been added. Though I think where I have gone is that when I tried this with array I had a mapping between "i" in the array and...
  5. Replies
    17
    Views
    1,071

    [SOLVED] Re: Memoization

    You are right, the fibonacci works as I've tested for some numbers though something has going wrong with storage I think which is why it's taking so long for greater numbers.
  6. Replies
    17
    Views
    1,071

    [SOLVED] Re: Memoization

    Sorry about the delay. Its for a project Euler problem, consumes a lot of memory.

    import java.math.BigInteger;
    import java.util.HashMap;
    import java.util.Map;


    public class ProjectEuler{...
  7. Replies
    17
    Views
    1,071

    [SOLVED] Re: Memoization

    Thank you so much, got it.
  8. Replies
    17
    Views
    1,071

    [SOLVED] Re: Memoization

    Under the "if not in memory" comment.

    mapping.put(n,bg);
  9. Replies
    17
    Views
    1,071

    [SOLVED] Memoization

    I'm trying to compute fibonacci for extremely large numbers so I'm using memoization and BigInteger.
    The trouble is I can't get it to work. I keep getting output -1 for all except the first and...
Results 1 to 9 of 9