aspose file tools*
The moose likes Java in General and the fly likes i got a different resolt than i was supposed to Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "i got a different resolt than i was supposed to" Watch "i got a different resolt than i was supposed to" New topic
Author

i got a different resolt than i was supposed to

alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
i tried to follow this recurstion
but instead of getting the resolt i expected i got
some thing realy different

http://img185.imageshack.us/my.php?image=img8290nf7.jpg



i entered (2,abcd)
i was supposed to get


cd
bd
bc
ad
ac
ab

instead i got some other answer using this diagram
can you tell me where i got ot wrong??

[ February 14, 2008: Message edited by: donaldth smithts ]
[ February 14, 2008: Message edited by: donaldth smithts ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39877
    
  28
Please use copy-and-paste to quote code, so you don't get misprints like "Public."
Please tell us what you think the recursion should do and what it is actually doing. It is doing exactly what you have told it to do.
Please work out how you are supposed to get "ab" from "abcd" which is where you are having problems.
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
I think you have to take another look at your algorithm.
You want to display substrings, but you don't manipulate your input string at all (except for making it longer by adding numbers at the end). How do you want to get from "abcd" to "cd"?
alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
you are right

is there any code that prints the subsets of the string??
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Not sure what you're asking for. If you're wanting a full solution to the problem, remember we are NotACodeMill.

If you're just asking how to get a substring of a string, you might consider String.substring() method.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
Whether you manipulate the string you send to the call or before you print it out, you might want to look at the String API and find what you need.

Particularly
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#substring(int,%20int)

might be useful


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
Don't get me started about those stupid light bulbs.
 
subject: i got a different resolt than i was supposed to