Click to See Complete Forum and Search --> : Please I want a solution to this question؟


salemqeshta
June 23rd, 2010, 12:40 PM
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 ?!!

salemqeshta
June 23rd, 2010, 12:47 PM
Note :
When I answered the question
The answer is 6
But some of my answer was 4
I am confused about now

salemqeshta
June 28th, 2010, 09:07 AM
the answer is 4
http://store2.up-00.com/Jun10/bPo33786.jpg
this quistion comming for me in the finale exam for Data Structuers

nuzzle
June 28th, 2010, 05:17 PM
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?

salemqeshta
July 2nd, 2010, 11:19 AM
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

Lazyboy
July 4th, 2010, 07:47 AM
How do you solve it using recurion ?

Lazyboy
July 5th, 2010, 09:36 AM
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 ?

nuzzle
July 5th, 2010, 07:50 PM
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?