here is Working Code Without DP in which we need To Find Out Minimum
Jumps & for every Jumps its Finding Maximum Step That Can Be Cover In
A Jump So that No. of Jumps Required is Minimized..
#include<stdio.h>
int main()
{
int arr[]={1 ,3, 5 ,8, 9, 2, 6 ,7 ,6, 8, 9};
int size=sizeof(a)/sizeof(int);
int i=0;int max,step,j,jump=0;
while( i< size)
{ jump++;
max=0;
step=0;
printf(" jump=%d \n",jump);
/*computes max distance it can cover in this jump*/
for(j=1;j<=arr[i];j++)
{
if(arr[i+j]+j>max)
{
max=arr[i+j]+j;
step=j;
printf(" max=%d \n",max);
printf(" step=%d \n",step);
}
}
i=i+step;
}
printf("Finally Jump %d \n ",jump);
return 0;
}
Now Remaining Job Need to Be Done is that How to reduce the
complexity..
Thanks & Regards
Shashank " "
--
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?hl=en.