This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/*This is a java program to implement Alexander Bogomolny’s permutation algorithm. This version of program computes all possible permutations of numbers from 1 to N using Alexander Bogomolyn’s algorithm.*/
importjava.util.Scanner;
publicclassAlexanderBogomolnyPermutation
{
staticintlevel=-1;
publicstaticvoidprint(int[]value,intn)
{
if(value.length!=0)
{
for(inti=0;i<value.length;i++)
{
System.out.print(value[i]+" ");
}
System.out.println();
}
}
publicstaticvoidvisit(int[]Value,intN,intk)
{
level=level+1;
Value[k]=level;
if(level==N)
print(Value,N);
else
for(inti=0;i<N;i++)
if(Value[i]==0)
visit(Value,N,i);
level=level-1;
Value[k]=0;
}
publicstaticvoidmain(String[]args)
{
Scannersc=newScanner(System.in);
System.out.println("Enter the size of the sequence:");