Anagram

Let's talk about algorithms!

Moderator: Board moderators

Post Reply
Tanu
Learning poster
Posts: 70
Joined: Sun May 29, 2005 12:46 pm
Location: Mars

Anagram

Post by Tanu »

My friend named Pinky...
I can called her....
KINPY,NIPKY,KINPY,PIKNY...
By keeping vowel in the right position
Hi anyone help me to learn about Anagram...
I failed to solve anagram problems.....
PLZ help...
Fixxxer
New poster
Posts: 5
Joined: Tue Aug 30, 2005 6:20 pm

Post by Fixxxer »

try STL next_permutation
kenneth
New poster
Posts: 24
Joined: Wed Mar 02, 2005 12:29 am

Post by kenneth »

If you want to check if two words s1, s2 are anagrams,

perform sorting on both s1 and s2 in term of the characters. If the result of both strings are the same, then they are anagrams =)
Tanu
Learning poster
Posts: 70
Joined: Sun May 29, 2005 12:46 pm
Location: Mars

Sorry

Post by Tanu »

Sorry i'm failed again...
I wanna make permutation of a given string....
Example "Killer"....
I wanna know the algorithm of permute under a rule...
Think like that keeping l in the outer side...
or some thing like keeping r only in odd position...
Plz help...
kenneth
New poster
Posts: 24
Joined: Wed Mar 02, 2005 12:29 am

Post by kenneth »

Tanu, like Fixxxer said, next_permutation will do your trick. However, it may be a bit slow depending on what you need to do.

Furthermore, should you be trying to solve an ACM problem, it would be helpful to tell us the problem number so that we can look at the spec.
Tanu
Learning poster
Posts: 70
Joined: Sun May 29, 2005 12:46 pm
Location: Mars

About my trouble

Post by Tanu »

Kenneth,Hi
I'm talking about any problems abt anagram in acm...
Let 146 I have take the way ->
1. first i find i scan the given string from left to right to find the rightmost charecter(nth char) that has its sussessor(in mth pos).. Its works okey.
2. Next is swapping it with with its sussessor(nth with mth).
3. nest swap from n+1 to stringlength(using bubble sort).

Example:
"asssdfrcab"
step 1: 'f' has sussesor 'r'
step 2: swap ->asssdrfcab
step 3: sort ->asssrabcf
Its currect but may not work in many ways ...
can you say why?
another 195 made sol by back tracking got ole...
plz help
Thanks
Tanu
Learning poster
Posts: 70
Joined: Sun May 29, 2005 12:46 pm
Location: Mars

late

Post by Tanu »

net is not available frequently so may late(sorry)
tuman
New poster
Posts: 24
Joined: Sat Oct 22, 2005 7:30 pm
Location: CUET
Contact:

Post by tuman »

tanvir_cuet,
Yes u r right :lol: :D :) :( :o :-? 8) :lol: :x :evil: :cry: :oops: :P :roll: :wink:

thanks a lot tanu......
Post Reply

Return to “Algorithms”