m_ashiq88
01-29-2005, 07:38 PM
VB6
Guys I have a really big challenge set to me. I have been asked by my cousin to generate an iterative algorithm with (FOR NEXT Loop) that undertakes the same task as the following recursive algorithm.
This is the recursive algorithm:
Function Mystery (X(), N)
IF N=1 THEN
Mystery = 1
ELSE
Temp = Mystery(X(), N-1)
IF X(N)>= X(Temp) THEN
Mystery = N
ELSE
Mystery = Temp
ENDIF
ENDIF
End Function Mystery
I will be extremely grateful if you can help me with this..
Thanks in advance...
Guys I have a really big challenge set to me. I have been asked by my cousin to generate an iterative algorithm with (FOR NEXT Loop) that undertakes the same task as the following recursive algorithm.
This is the recursive algorithm:
Function Mystery (X(), N)
IF N=1 THEN
Mystery = 1
ELSE
Temp = Mystery(X(), N-1)
IF X(N)>= X(Temp) THEN
Mystery = N
ELSE
Mystery = Temp
ENDIF
ENDIF
End Function Mystery
I will be extremely grateful if you can help me with this..
Thanks in advance...