Solved

String permutation pseudo Code

Posted on 2011-09-14
5
828 Views
Last Modified: 2012-05-12
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);
                  }
           }

}

Open in new window


0
Comment
Question by:N_Sri
  • 2
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
tampnic earned 500 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

by:tampnic
tampnic earned 500 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

by:N_Sri
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

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now