I have to basically write a fuction that does the inmemoized recursion and count the number of times is called..which i did..

the second part is that i dont understand which is to create a global array of 100 and calculate the function using memoization...

can some one help..this is the first part

import java.util.Scanner;

public class Fib{
static int calls;
public static void main(String[] args){
int fib;
int n;
Scanner scan = new Scanner(System.in);
System.out.println("Input a number");
n = scan.nextInt();
System.out.println(" " + RecurFib(n) + " " + calls);

}
int count = 0;
public static int RecurFib (int n){
calls ++;
if (n<2){

int answer = n;
return answer;
}else{
int answer = RecurFib(n-1) + RecurFib(n-2);
return answer;
}
}

basically the second part has to do the same thing as the first one but now using memoization...

here is an example of the outputs "numbers" that it should have..but the program is in C++ i think, and I can't understand it too well.

where's the value of calls in the program? you wouldnt happen to be in randall's class at rutgers would u

yes i am..and you? did he collected the program.. i think we still have time..to send it right?

naw i guess we can send it wenever... i went to talk 2 him today about why my program wont compile and i still cant figure it out.... i noticed u copied the program some1 replied to me with and what i dont understand is that first static int calls is declared as a global variable up top and then it says int count = 0.... where is the value for calls? in the program? isnt it supposed to say calls = 0;

i guess is because the calls ++ is inside the recursive function therefore.. the count will keep adding.. if you trie to punt count ++ it wont work..

im having trouble figuring out the second part.. the memoization part.. ..have you been successful with it?

im me hustla2489

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.