Answers for "Top down approach is used for."

1

top down approach

//===========Top_down implementation (just recursive)
fib(int n){
	if(n<2){
	return n;
	return fib(n-1) + fib(n-2);
	}
}

//===========Top_down implementation (recursive + memoization)

fib(int n){
	if(n<2){
	return n;

	if(cache[n] is defined)
		return cache[n];

	return cache[n]=fib(n-1) + fib(n-2);
	}
}

//===========Top_down implementation(avoid recursion , only tabulation)

fib(int n){
	int cache[] = new int [n+1];

	//base case;
	cache[0]=1;
	cache[1]=1;

	for(int i=2; i<=n; i++){
	cache[1] = cache[i-1] +cache[i -2];
	}
	return cache[n];
}
Posted by: Guest on October-13-2021
0

top down approach

Testing takes place from top to bottom. 
High-level modules are tested first and
then low-level modules and finally 
integrating the low-level modules to
a high level to ensure the system is
working as intended. Stubs are used as
a temporary module if a module is 
not ready for integration testing.
Posted by: Guest on January-17-2021

Code answers related to "Top down approach is used for."

Browse Popular Code Answers by Language