0

return printLCS(i-1, j-1) + index(x, i);

i found this in a recursive java program, well that is being done is return index(x, i) (returns a character) and same time continue recursion?

4
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by JamesCherrill
0

index() & printLCS in a java custom functions, printLCS makes recursion, well, may call recursion like this and same time output to screen, all in one line? yes you can / no you can not

script worked from book

0

I mean call two functions with "+", one proceed the recursion, the other output string to screen?

0

What is happening there first both methods are executed and then results are either added if numeric value (5+3 = 8), or index(x, i) is appended to printLCS(i-1, j-1) (south + west = southwest)

0

Yes but one function is recursive call itself: eg

public printLCS(i-1, j-1) {
.....
.....
printLCS(i, j)
.....
.....
}

the other[index(x, i)] returns directly a string

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

0

That doesn't matter printLCS must have some return type and this added up with the return from other method. As I said in first post, without proper code snippets nobody can be wiser...

0

the

else {
return printLCS(i-1, j-1) + index(x, i);
}

is equivalent to

else {
printLCS(i-1, j-1);
return index(x, i);
}

Edited by peter_budo: Keep It Clear - Do wrap your programming code blocks within [code] ... [/code] tags

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.