Well This is Certainly lacks logic behind the Coder.

Please remember EVERY RECURSIVE PROGRAM Need Break for certain condition.

here mid keep updating without knowing when to finish the recursion so the
code never goes below line seven..


I appreciate this way of Creating LOOP although its a good CPU hogging
program..


Keep Working... :P

On Tue, Aug 2, 2011 at 2:30 PM, Gayathri Anandan <
[email protected]> wrote:

> I didnt get any output for this pgm. I think its keep on running and
> got struck in the 6th line. Plz help with this.
>
> 1 #include<stdio.h>
> 2 #include<conio.h>
> 3 int max(int a[10],int s,int e)
> 4 {
> 5 int res,res1,res2,mid=(s+e-1)/2;
> 6 res1=max(a,s,mid+1);
> 7 res2=max(a,mid+1,e);
> 8 res=res1>res2?res1:res2;
> 9 return res;
> 10 }
> void main()
> {
> int a[]={2,4,1,2,3,8,7,6,9},maxval;
> maxval=max(a,0,9);
> printf("%d",maxval);
> getch();
> }
>
> --
> 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.
>
>

-- 
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.

Reply via email to