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

Favorite algorithm

Name: Anonymous 2010-06-18 0:42

Please post about your favorite algorithm.

Mine is KMP algorithm for string searching, it is very nice.

All kinds welcome.

Name: Anonymous 2010-06-18 10:13

>>9
#define VALID_FIBONACCI 12
/* fibonacci table, precomputed for execution speed */
static const unsigned long long fibs_table[VALID_FIBONACCI] = { 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, }; /* add more if required */
unsigned long long fibs (unsigned int n) {
        if (n <= VALID_FIBONACCI)
                return fibs_table[n];
        else
                return (unsigned int) -1; /* TODO throw 'out of bounds' exception */
}

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