Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

epsilonnawt Group Title

A program in Bluej platform for generating permutations of a number?

  • 2 years ago
  • 2 years ago

  • This Question is Open
  1. krithika Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    import java.util.*; public class Permutation { static Scanner sc=new Scanner(System.in); public char[] arr; public int count; public Permutation(String word) { arr=word.toUpperCase().toCharArray(); count=0; } public void permute(int start) { if(start==arr.length-1) // TRIVIAL CASE { System.out.print(arr);System.out.print(" "); if((getCount()+1)%5==0)System.out.println(); count++; return; } for(int i=start;i<arr.length;i++) { // SWAPPING i-th AND start-th ELEMENT char temp=arr[i]; arr[i]=arr[start]; arr[start]=temp; permute(start+1); // SWAPPING TO ORIGINAL POSITION temp=arr[i]; arr[i]=arr[start]; arr[start]=temp; } } public int getCount(){ return count; } public static void main(String args[]) { System.out.print("Enter The Word : "); String word=sc.next(); System.out.println(); Permutation obj=new Permutation(word); obj.permute(0); // BEGIN WITH 1ST CHAR System.out.println("\nTotal No Of Permutation : "+obj.getCount()); } }

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...


  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.