Here is a simple program to print the frog's possible paths:

#include <stdio.h>

int main()
{
        char a['K'-'A'+1]={'A'}, n=0;
        for( int i = 0 ; i <= (1<<('K'-'A'-2)) ; i++ )
        {
                int j = 0;
                do
                {
                        a[j+1] = a[j] + (((i>>j)&1) + 1);
                        j++;
                } while (a[j] < 'K');
                if( a[j] == 'K' && (i>>j) == 0 )
                {
                        printf("%4i: ", ++n);
                        for( int k = 0 ; k <= j ; k++ )
                                printf("%c", a[k]);
                        printf("\n");
                }
        }
        return 0;
}

Dave

On Feb 12, 12:13 am, "Abhijeet Singh" <[EMAIL PROTECTED]> wrote:
> I have stones numbered from A-K and I have a Frog which can make a jump
> of one stone at a time or two stones at a time but no more then that.
> I will explain , assumes my stones are ABCDEFG.... K
> At any point say A, the frog can jump from A-B or from A-C but not from A-D
> or otherwise, when it reaches J, it can only make a hop of 1 as there are no
> more stones after that. Frog can not jump backwards.
>
> In how many ways can he reach from A-K, give a recursive formula for that.
>
> Print all possible paths that the Frog can choose while moving from A-K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to