-
June 23rd, 2010, 12:40 PM
#1
Please I want a solution to this question؟
public int Evaluate(s,t){
for loop {
if(s==0 || t==0)
return 0;
}
else if{
y=Evaluate(s,t-1);
return s+y;
}
}
By using stack to find
z=Evaluate(2,2)=???????????????????
Dont use Recourion
please help me ?!!
-
June 23rd, 2010, 12:47 PM
#2
Re: Please I want a solution to this question؟
Note :
When I answered the question
The answer is 6
But some of my answer was 4
I am confused about now
-
June 28th, 2010, 09:07 AM
#3
Re: Please I want a solution to this question؟
the answer is 4
http://store2.up-00.com/Jun10/bPo33786.jpg
this quistion comming for me in the finale exam for Data Structuers
-
June 28th, 2010, 05:17 PM
#4
Re: Please I want a solution to this question؟
I'm not quite sure what you're asking.
Is Evaluate given in some real language or is it pseudocode? What does,
for loop {
mean?
-
July 2nd, 2010, 11:19 AM
#5
Re: Please I want a solution to this question؟
oh yes
i dont main for loop
I do not remember the text of a good question
****************************************
public int Evaluate(s,t){
for {
if(s==0 || t==0)
return 0;
}
else if{
y=Evaluate(s,t-1);
return s+y;
}
}
****************************************
By using stack to find
z=Evaluate(2,2)=???????????????????
Dont use Recourion
The solution described in the link http://www.4shared.com/photo/0Nu72OYi/9999999999.html
Is the correct solution, as told by Dr.
Thus, the question was almost
Thank you for your interest
-
July 4th, 2010, 07:47 AM
#6
Re: Please I want a solution to this question؟
How do you solve it using recurion ?
-
July 5th, 2010, 09:36 AM
#7
Re: Please I want a solution to this question؟
Hello, strange, so strange, I am still think it is 0 not 4
1.public int Evaluate(s,t){
2.{
3.if(s==0 || t==0)
4.return 0;
5.}
6.else if{
7.y=Evaluate(s,t-1); // this
8.return s+y;
9.}
10.}
Line 7 rerun line 1, so no value is put for y
t=2-1=1
s=2
line 3 checks t and s
unsatisfactorily, line 6 come again, line 7 again rerun line 1, still no value for y
t=1-1=0
s=2
Now t=0
line 2-3 checks t=0 so satisfied it returns 0
So the final result is 0, line 8 never reaches
Answer=0
Am I right ?
Hello, I am a college junior
-
July 5th, 2010, 07:50 PM
#8
Re: Please I want a solution to this question؟
Originally Posted by Lazyboy
Am I right ?
Does it stay put now, the 1 to 10 lines? Is this the version of the Evaluate function you're asking about?
And what are you asking again please? Be precise.
And who is salemqeshta in relation to lazyboy?
Sorry for letting out some steam here but why is it so god dammed hard to state a problem in a precise and understandable way?
Last edited by nuzzle; July 5th, 2010 at 08:45 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|