Solved

String permutation pseudo Code

Posted on 2011-09-14
5
877 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
[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
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run tasks synchronously in background thread 19 78
c#, case, if 4 35
ComboBox to String Not Working 5 39
Run software updates from the website 6 45
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

739 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