As far as I know, If I want an iterative algorithm with O(n^m)
I just have to use m
number of for
s on n array elements.
Is there any way of building a O(n^m)
complexity algorithm (recursive way)? I'd like some explanation on a given algorithm.
This wastes O(n^m) time in a recursive way.
void waste ( unsigned n, unsigned m ) {
if ( m ) for ( unsigned i=0; i<n; i++ ) waste(n,m-1);
}
Actually, that was a simple question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.