Re: Recursive Search Algorithms

From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 02/09/04


Date: Mon, 09 Feb 2004 05:54:51 GMT


"Brian" <brian@return.net> wrote in message
news:IuCVb.27677$fZ6.25891@lakeread06...
> Can someone point me where I can look at linear and binary recursive
> search algorithms?

Simple example of 'linear recursive search':

/* if 'data' is NULL, returns NULL */
char *search(char *data, int to_find)
{
    return data
        ? *data /* data != NULL */
            ? *data == to_find /* *data != 0 */
                ? data /* *data == to_find */
                : search(++data, to_find) /* *data != to_find */
            : 0 /* *data == 0 */
        : data; /* data == NULL */
}

I'm sure www.google.com can find many more examples and
information.

-Mike