Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# String permutation pseudo Code

Posted on 2011-09-14
Medium Priority
941 Views
Can you please give pseudo code  algorithm for this code

``````using System;
using System.Text;

namespace Permutations
{
class Permute
{
private void swap (ref char a,ref char b)
{
if(a==b)return;
a^=b;
b^=a;
a^=b;
}

public void Set_Permutation(char[] list)
{
int arrayLength=list.Length-1;
Permutation_Method(list,0,arrayLength);
}

private void Permutation_Method (char[] list,int k,int m)
{
// k intial index passed
// m size of char array
int i;
if(k == m)  // ---------- What is this Condition ?
{
Console.Write(list);
Console.WriteLine(" ");
}
else
for(i = k; i <= m; i++) //  why i=k ?
{
swap(ref list[k], ref list[i]);  // what does this Swap doing ?

//recursive call
Permutation_Method (list, k+1, m);

swap(ref list[k], ref list[i]);   // what does this Swap doing ?
}
}
}

class Class1
{
static void Main()
{

Permute objPermutation =new Permute();
string str="abc";
char[] mycharArray=str.ToCharArray();
/*calling the permute*/
objPermutation.Set_Permutation(mycharArray);
}
}

}
``````

0
Question by:N_Sri
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 7

Accepted Solution

tampnic earned 1000 total points
ID: 36542340
Is http://www.dreamincode.net/code/snippet4662.htm what you are trying to accomplish?

http://weblogs.sqlteam.com/mladenp/archive/2006/03/19/9350.aspx gives a good explanation of string reversal using recursion.

Cheers,
Chris
0

LVL 7

Assisted Solution

tampnic earned 1000 total points
ID: 36542360
Disregard the code snippet above - I was making a couple of notes - forgot to remove the code from my final post. Some comments in it aren't exactly correct. The links I gave you are good though.

Cheers,
Chris
0

Author Comment

ID: 36545166
@tampnic

I am sure you did not understood the code .The code is for  String Permutation.

I am requesting String permutation pseudo code for the which I gave
0

Author Closing Comment

ID: 36707665
You did not understood the question.  Very poor answer
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
###### Suggested Courses
Course of the Month11 days, 1 hour left to enroll