SlideShare a Scribd company logo
1 of 5
Download to read offline
Code:
import java.util.Random;
import java.util.Scanner;
class Test{
static void permute(int[] a, int k){
if (k == a.length){
for (int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println();
}else{
for (int i = k; i < a.length; i++){
int temp = a[k];
a[k] = a[i];
a[i] = temp;
permute(a, k + 1);
temp = a[k];
a[k] = a[i];
a[i] = temp;
}
}
}
public static void main(String args[])
{
Random random = new Random();
Scanner sc = new Scanner(System.in);
System.out.print("Enter the length of list: ");
int N = sc.nextInt();
int[] sequence = new int[N];
for (int i = 1; i < N+1; i++)
sequence[i-1] = i;
System.out.println("The original sequence is: ");
for (int i = 0; i < N; i++)
System.out.print(sequence[i] + " ");
System.out.println(" The permuted sequences are as follows: ");
permute(sequence, 0);
sc.close();
}
}
Output:
Enter the length of list: 4
The original sequence is:
1 2 3 4
The permuted sequences are:
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 3 2
1 4 2 3
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 3 1
2 4 1 3
3 2 1 4
3 2 4 1
3 1 2 4
3 1 4 2
3 4 1 2
3 4 2 1
4 2 3 1
4 2 1 3
4 3 2 1
4 3 1 2
4 1 3 2
4 1 2 3
Solution
Code:
import java.util.Random;
import java.util.Scanner;
class Test{
static void permute(int[] a, int k){
if (k == a.length){
for (int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
System.out.println();
}else{
for (int i = k; i < a.length; i++){
int temp = a[k];
a[k] = a[i];
a[i] = temp;
permute(a, k + 1);
temp = a[k];
a[k] = a[i];
a[i] = temp;
}
}
}
public static void main(String args[])
{
Random random = new Random();
Scanner sc = new Scanner(System.in);
System.out.print("Enter the length of list: ");
int N = sc.nextInt();
int[] sequence = new int[N];
for (int i = 1; i < N+1; i++)
sequence[i-1] = i;
System.out.println("The original sequence is: ");
for (int i = 0; i < N; i++)
System.out.print(sequence[i] + " ");
System.out.println(" The permuted sequences are as follows: ");
permute(sequence, 0);
sc.close();
}
}
Output:
Enter the length of list: 4
The original sequence is:
1 2 3 4
The permuted sequences are:
1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 3 2
1 4 2 3
2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 3 1
2 4 1 3
3 2 1 4
3 2 4 1
3 1 2 4
3 1 4 2
3 4 1 2
3 4 2 1
4 2 3 1
4 2 1 3
4 3 2 1
4 3 1 2
4 1 3 2
4 1 2 3

More Related Content

Similar to Codeimport java.util.Random; import java.util.Scanner; clas.pdf

java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfkokah57440
 
クイズプログラム
クイズプログラムクイズプログラム
クイズプログラムMinori Fukuda
 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdfactocomputer
 
import java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfimport java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfLAMJM
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
CountStringCharacters.javaimport java.util.Scanner; public cla.pdf
CountStringCharacters.javaimport java.util.Scanner; public cla.pdfCountStringCharacters.javaimport java.util.Scanner; public cla.pdf
CountStringCharacters.javaimport java.util.Scanner; public cla.pdfpremsrivastva8
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginnersishan0019
 
Demonstrating bully algorithm in java
Demonstrating bully algorithm in javaDemonstrating bully algorithm in java
Demonstrating bully algorithm in javaNagireddy Dwarampudi
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfoptokunal1
 
CODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfCODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfanurag1231
 
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfSumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfankkitextailes
 
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfimport java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfadhityalapcare
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...MaruMengesha
 
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdfJAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdfkarymadelaneyrenne19
 

Similar to Codeimport java.util.Random; import java.util.Scanner; clas.pdf (19)

java slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdfjava slip for bachelors of business administration.pdf
java slip for bachelors of business administration.pdf
 
クイズプログラム
クイズプログラムクイズプログラム
クイズプログラム
 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdf
 
import java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfimport java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdf
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
CountStringCharacters.javaimport java.util.Scanner; public cla.pdf
CountStringCharacters.javaimport java.util.Scanner; public cla.pdfCountStringCharacters.javaimport java.util.Scanner; public cla.pdf
CountStringCharacters.javaimport java.util.Scanner; public cla.pdf
 
Java practice programs for beginners
Java practice programs for beginnersJava practice programs for beginners
Java practice programs for beginners
 
Demonstrating bully algorithm in java
Demonstrating bully algorithm in javaDemonstrating bully algorithm in java
Demonstrating bully algorithm in java
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 
CODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdfCODEimport java.util.; public class test { public static voi.pdf
CODEimport java.util.; public class test { public static voi.pdf
 
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfSumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
 
Oot practical
Oot practicalOot practical
Oot practical
 
Huraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docxHuraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docx
 
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdfimport java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
import java-util-Arrays- import java-io-PrintWriter- import java-io-Fi.pdf
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
Sam wd programs
Sam wd programsSam wd programs
Sam wd programs
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
 
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdfJAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
 

More from anupamselection

1. D2. A3. D4.DSolution1. D2. A3. D4.D.pdf
1. D2. A3. D4.DSolution1. D2. A3. D4.D.pdf1. D2. A3. D4.DSolution1. D2. A3. D4.D.pdf
1. D2. A3. D4.DSolution1. D2. A3. D4.D.pdfanupamselection
 
1) pH is alkalotic and it is caused due to combined (mixed) alkalosi.pdf
1) pH is alkalotic and it is caused due to combined (mixed) alkalosi.pdf1) pH is alkalotic and it is caused due to combined (mixed) alkalosi.pdf
1) pH is alkalotic and it is caused due to combined (mixed) alkalosi.pdfanupamselection
 
1) Economical for transport of goods and services2) Reducing traff.pdf
1) Economical for transport of goods and services2) Reducing traff.pdf1) Economical for transport of goods and services2) Reducing traff.pdf
1) Economical for transport of goods and services2) Reducing traff.pdfanupamselection
 
There are some general processes which you need to follow while crea.pdf
There are some general processes which you need to follow while crea.pdfThere are some general processes which you need to follow while crea.pdf
There are some general processes which you need to follow while crea.pdfanupamselection
 
All of the above.Solution All of the above..pdf
 All of the above.Solution All of the above..pdf All of the above.Solution All of the above..pdf
All of the above.Solution All of the above..pdfanupamselection
 
Ques-1A keystone species is defined as a species, which has an ex.pdf
Ques-1A keystone species is defined as a species, which has an ex.pdfQues-1A keystone species is defined as a species, which has an ex.pdf
Ques-1A keystone species is defined as a species, which has an ex.pdfanupamselection
 
PO42- is produced when CaPO4 is dissolved. Adding acid to the soluti.pdf
PO42- is produced when CaPO4 is dissolved. Adding acid to the soluti.pdfPO42- is produced when CaPO4 is dissolved. Adding acid to the soluti.pdf
PO42- is produced when CaPO4 is dissolved. Adding acid to the soluti.pdfanupamselection
 
picture(figure) is not clearSolutionpicture(figure) is not cle.pdf
picture(figure) is not clearSolutionpicture(figure) is not cle.pdfpicture(figure) is not clearSolutionpicture(figure) is not cle.pdf
picture(figure) is not clearSolutionpicture(figure) is not cle.pdfanupamselection
 
package length; A Length is an object that has a length and .pdf
package length; A Length is an object that has a length and .pdfpackage length; A Length is an object that has a length and .pdf
package length; A Length is an object that has a length and .pdfanupamselection
 
Name used on OSIName Used in TCPIP networksLayer 1(Physical)L.pdf
Name used on OSIName Used in TCPIP networksLayer 1(Physical)L.pdfName used on OSIName Used in TCPIP networksLayer 1(Physical)L.pdf
Name used on OSIName Used in TCPIP networksLayer 1(Physical)L.pdfanupamselection
 
Monthly interest rate=1212=1Present value(PV) of monthly payment.pdf
Monthly interest rate=1212=1Present value(PV) of monthly payment.pdfMonthly interest rate=1212=1Present value(PV) of monthly payment.pdf
Monthly interest rate=1212=1Present value(PV) of monthly payment.pdfanupamselection
 
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdf
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdfLab1.javaimport java.util.Scanner;package public class Lab1 .pdf
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdfanupamselection
 
Interest coverage=EBITinterest expensewhich is equal to=(40020.pdf
Interest coverage=EBITinterest expensewhich is equal to=(40020.pdfInterest coverage=EBITinterest expensewhich is equal to=(40020.pdf
Interest coverage=EBITinterest expensewhich is equal to=(40020.pdfanupamselection
 
In this module, you will learn some basics about operating in Object.pdf
In this module, you will learn some basics about operating in Object.pdfIn this module, you will learn some basics about operating in Object.pdf
In this module, you will learn some basics about operating in Object.pdfanupamselection
 
When comparing the R groups of these to amino aci.pdf
                     When comparing the R groups of these to amino aci.pdf                     When comparing the R groups of these to amino aci.pdf
When comparing the R groups of these to amino aci.pdfanupamselection
 
Malonic Acid Water Soluble Methyl Alcohol Solu.pdf
                     Malonic Acid  Water Soluble Methyl Alcohol Solu.pdf                     Malonic Acid  Water Soluble Methyl Alcohol Solu.pdf
Malonic Acid Water Soluble Methyl Alcohol Solu.pdfanupamselection
 
It is true that ionization energy is required to .pdf
                     It is true that ionization energy is required to .pdf                     It is true that ionization energy is required to .pdf
It is true that ionization energy is required to .pdfanupamselection
 
Ionic compounds form when the electronegativity d.pdf
                     Ionic compounds form when the electronegativity d.pdf                     Ionic compounds form when the electronegativity d.pdf
Ionic compounds form when the electronegativity d.pdfanupamselection
 
If R is reflexive, then xRy means yRx; but then, .pdf
                     If R is reflexive, then xRy means yRx; but then, .pdf                     If R is reflexive, then xRy means yRx; but then, .pdf
If R is reflexive, then xRy means yRx; but then, .pdfanupamselection
 

More from anupamselection (20)

1. D2. A3. D4.DSolution1. D2. A3. D4.D.pdf
1. D2. A3. D4.DSolution1. D2. A3. D4.D.pdf1. D2. A3. D4.DSolution1. D2. A3. D4.D.pdf
1. D2. A3. D4.DSolution1. D2. A3. D4.D.pdf
 
1) pH is alkalotic and it is caused due to combined (mixed) alkalosi.pdf
1) pH is alkalotic and it is caused due to combined (mixed) alkalosi.pdf1) pH is alkalotic and it is caused due to combined (mixed) alkalosi.pdf
1) pH is alkalotic and it is caused due to combined (mixed) alkalosi.pdf
 
1) Economical for transport of goods and services2) Reducing traff.pdf
1) Economical for transport of goods and services2) Reducing traff.pdf1) Economical for transport of goods and services2) Reducing traff.pdf
1) Economical for transport of goods and services2) Reducing traff.pdf
 
There are some general processes which you need to follow while crea.pdf
There are some general processes which you need to follow while crea.pdfThere are some general processes which you need to follow while crea.pdf
There are some general processes which you need to follow while crea.pdf
 
All of the above.Solution All of the above..pdf
 All of the above.Solution All of the above..pdf All of the above.Solution All of the above..pdf
All of the above.Solution All of the above..pdf
 
Ques-1A keystone species is defined as a species, which has an ex.pdf
Ques-1A keystone species is defined as a species, which has an ex.pdfQues-1A keystone species is defined as a species, which has an ex.pdf
Ques-1A keystone species is defined as a species, which has an ex.pdf
 
PO42- is produced when CaPO4 is dissolved. Adding acid to the soluti.pdf
PO42- is produced when CaPO4 is dissolved. Adding acid to the soluti.pdfPO42- is produced when CaPO4 is dissolved. Adding acid to the soluti.pdf
PO42- is produced when CaPO4 is dissolved. Adding acid to the soluti.pdf
 
picture(figure) is not clearSolutionpicture(figure) is not cle.pdf
picture(figure) is not clearSolutionpicture(figure) is not cle.pdfpicture(figure) is not clearSolutionpicture(figure) is not cle.pdf
picture(figure) is not clearSolutionpicture(figure) is not cle.pdf
 
package length; A Length is an object that has a length and .pdf
package length; A Length is an object that has a length and .pdfpackage length; A Length is an object that has a length and .pdf
package length; A Length is an object that has a length and .pdf
 
Name used on OSIName Used in TCPIP networksLayer 1(Physical)L.pdf
Name used on OSIName Used in TCPIP networksLayer 1(Physical)L.pdfName used on OSIName Used in TCPIP networksLayer 1(Physical)L.pdf
Name used on OSIName Used in TCPIP networksLayer 1(Physical)L.pdf
 
Monthly interest rate=1212=1Present value(PV) of monthly payment.pdf
Monthly interest rate=1212=1Present value(PV) of monthly payment.pdfMonthly interest rate=1212=1Present value(PV) of monthly payment.pdf
Monthly interest rate=1212=1Present value(PV) of monthly payment.pdf
 
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdf
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdfLab1.javaimport java.util.Scanner;package public class Lab1 .pdf
Lab1.javaimport java.util.Scanner;package public class Lab1 .pdf
 
Interest coverage=EBITinterest expensewhich is equal to=(40020.pdf
Interest coverage=EBITinterest expensewhich is equal to=(40020.pdfInterest coverage=EBITinterest expensewhich is equal to=(40020.pdf
Interest coverage=EBITinterest expensewhich is equal to=(40020.pdf
 
In this module, you will learn some basics about operating in Object.pdf
In this module, you will learn some basics about operating in Object.pdfIn this module, you will learn some basics about operating in Object.pdf
In this module, you will learn some basics about operating in Object.pdf
 
y = 12 x=0 z=0 .pdf
                     y = 12 x=0 z=0                                  .pdf                     y = 12 x=0 z=0                                  .pdf
y = 12 x=0 z=0 .pdf
 
When comparing the R groups of these to amino aci.pdf
                     When comparing the R groups of these to amino aci.pdf                     When comparing the R groups of these to amino aci.pdf
When comparing the R groups of these to amino aci.pdf
 
Malonic Acid Water Soluble Methyl Alcohol Solu.pdf
                     Malonic Acid  Water Soluble Methyl Alcohol Solu.pdf                     Malonic Acid  Water Soluble Methyl Alcohol Solu.pdf
Malonic Acid Water Soluble Methyl Alcohol Solu.pdf
 
It is true that ionization energy is required to .pdf
                     It is true that ionization energy is required to .pdf                     It is true that ionization energy is required to .pdf
It is true that ionization energy is required to .pdf
 
Ionic compounds form when the electronegativity d.pdf
                     Ionic compounds form when the electronegativity d.pdf                     Ionic compounds form when the electronegativity d.pdf
Ionic compounds form when the electronegativity d.pdf
 
If R is reflexive, then xRy means yRx; but then, .pdf
                     If R is reflexive, then xRy means yRx; but then, .pdf                     If R is reflexive, then xRy means yRx; but then, .pdf
If R is reflexive, then xRy means yRx; but then, .pdf
 

Recently uploaded

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Codeimport java.util.Random; import java.util.Scanner; clas.pdf

  • 1. Code: import java.util.Random; import java.util.Scanner; class Test{ static void permute(int[] a, int k){ if (k == a.length){ for (int i = 0; i < a.length; i++){ System.out.print(a[i] + " "); } System.out.println(); }else{ for (int i = k; i < a.length; i++){ int temp = a[k]; a[k] = a[i]; a[i] = temp; permute(a, k + 1); temp = a[k]; a[k] = a[i]; a[i] = temp; } } } public static void main(String args[]) { Random random = new Random(); Scanner sc = new Scanner(System.in); System.out.print("Enter the length of list: "); int N = sc.nextInt(); int[] sequence = new int[N]; for (int i = 1; i < N+1; i++)
  • 2. sequence[i-1] = i; System.out.println("The original sequence is: "); for (int i = 0; i < N; i++) System.out.print(sequence[i] + " "); System.out.println(" The permuted sequences are as follows: "); permute(sequence, 0); sc.close(); } } Output: Enter the length of list: 4 The original sequence is: 1 2 3 4 The permuted sequences are: 1 2 3 4 1 2 4 3 1 3 2 4 1 3 4 2 1 4 3 2 1 4 2 3 2 1 3 4 2 1 4 3 2 3 1 4 2 3 4 1 2 4 3 1 2 4 1 3 3 2 1 4 3 2 4 1 3 1 2 4 3 1 4 2 3 4 1 2 3 4 2 1 4 2 3 1
  • 3. 4 2 1 3 4 3 2 1 4 3 1 2 4 1 3 2 4 1 2 3 Solution Code: import java.util.Random; import java.util.Scanner; class Test{ static void permute(int[] a, int k){ if (k == a.length){ for (int i = 0; i < a.length; i++){ System.out.print(a[i] + " "); } System.out.println(); }else{ for (int i = k; i < a.length; i++){ int temp = a[k]; a[k] = a[i]; a[i] = temp; permute(a, k + 1); temp = a[k]; a[k] = a[i]; a[i] = temp; } } } public static void main(String args[]) {
  • 4. Random random = new Random(); Scanner sc = new Scanner(System.in); System.out.print("Enter the length of list: "); int N = sc.nextInt(); int[] sequence = new int[N]; for (int i = 1; i < N+1; i++) sequence[i-1] = i; System.out.println("The original sequence is: "); for (int i = 0; i < N; i++) System.out.print(sequence[i] + " "); System.out.println(" The permuted sequences are as follows: "); permute(sequence, 0); sc.close(); } } Output: Enter the length of list: 4 The original sequence is: 1 2 3 4 The permuted sequences are: 1 2 3 4 1 2 4 3 1 3 2 4 1 3 4 2 1 4 3 2 1 4 2 3 2 1 3 4 2 1 4 3 2 3 1 4 2 3 4 1 2 4 3 1 2 4 1 3
  • 5. 3 2 1 4 3 2 4 1 3 1 2 4 3 1 4 2 3 4 1 2 3 4 2 1 4 2 3 1 4 2 1 3 4 3 2 1 4 3 1 2 4 1 3 2 4 1 2 3