954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help Adding Permutation In linked list

Here is my code so far and i`m editing it and adding some code, is there some one might tell me that this is the right way of coding list in permutation.

This program is not yet complete.

package man;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;

public class ScrambleWord {
	
	public static void main(String []args)throws IOException{
		
		LinkedList scrambleList = new LinkedList();
		
        String str;
        
        for(int counter=1; counter<=3; counter++){
			scrambleList.add(new String(str));
			str = str+2;
			
        System.out.println("Enter a Word:");
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        str=br.readLine();
        System.out.println("Permutations are :");
        permute("", str);
        str=br.readLine();
        System.out.println("The First Item in the List is");
        }
    }

  public static void permute(String beginningString, String endingString) {
    if (endingString.length() <= 1)
      System.out.println(beginningString + endingString);
    else
      for (int i = 0; i < endingString.length(); i++) {
        try {
          String newString = endingString.substring(0, i) + endingString.substring(i + 1);

          permute(beginningString + endingString.charAt(i), newString);
        } catch (StringIndexOutOfBoundsException exception) {
          exception.printStackTrace();
        }
        
        
      }
  }
		
		
		
	}
PHkiDz
Newbie Poster
10 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 
way of coding list in permutation.


Can you explain what you want the code to do?

NormR1
Posting Expert
Moderator
6,677 posts since Jun 2010
Reputation Points: 1,138
Solved Threads: 656
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: