Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

hay look at my recursive pow

Name: Anonymous 2009-03-04 20:14


#include <stdio.h>
#include <stdlib.h>

unsigned long long rpow(int n, int p) {
  return p ? p==1 ? n : n * rpow(n,p-1) : 1;
}

int main(int argc, char **argv) {
  if(argv[1])
    if(argv[2]) {
      int n = atoi(argv[1]);
      int p = atoi(argv[2]);
      printf("%llu\n",rpow(n,p));
    }
  return 0;
}

Name: Anonymous 2009-03-12 20:51

>>137
Table lookup is not constant unamortized time, you are wrong. The process of calculating this result is somewhat complex (due to all the seeming dynamic factors) and described in several papers on the subject, which I get the feeling you have not read. Go and troll in the FrozenVoid threads.

>>136
I said quite clearly the algorithm SOLVES THE MAZE. You would have a completely seperate algorithm for generating it, that would be to say the pow() function GENERATES the lookup tables it wants to use EVERY time it is called. Your argument is completely invalid. Is the time complexity of "Hello World!" in a Java Application O(n^3), because we have to account for the time complexity of the JVM loading sequence and complexities of the classloader, garbage collection and other such systems? I don't think so. The time complexity of a pow function that looks up pre computed values in a table is constant.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List