00:01
In this question, we have to list all possible ways by which people can line up for a photo.
00:08
So we have to write this code in java and our main input here is we have to list all ways where people can line up for a photo like this.
00:32
So here we have to for this we have to use all permutations of a list of strings.
00:43
So the program will read a list of one word names that and we will use a recursive method here for to create a recursive method to create an output all possible orders of the names that are given in the question and we have to separate them by a comma.
01:10
So here we have to it is given to us in the question that we have to use the template that is import .java import java .util .scanner.
01:30
So this is first then next we have to use is import import java .util .arraylist.
01:53
Arraylist so and we have to use of public class of photo lineups.
02:03
So this is important and by using this we will create a code in java to solve the program solve this query and write a program.
02:14
So let us see how we can write a program for this for that i'll use a basic java compiler.
02:22
So your first thing that we will do is we'll import the necessary packages that are mentioned to us in the question.
02:29
So these both packages we have introduced to the code will begin now by importing the scanner class from the java package to read the input from the user and the array class to store the names.
02:48
So now we will declare the class for photo lineups.
02:54
Here it is.
02:55
So as we can see that the declaration of the class is done.
03:02
But now we have to define the recursive method to print all permutations.
03:08
So for that we will use a public class static void to print all permutations possible using a string name list.
03:23
So here are the base cases if the name list is empty we have a valid permutation.
03:28
So by using that logic we will use a if else loop as i'll show you we will use a if else loop here.
03:40
This will print the names in the permutation list separated by commas.
03:46
This was given to us in the question.
03:50
So now you're as you can see we have given a base case.
03:58
So the base case here means that if the name list is empty it means that we have a valid permutation.
04:06
In this case the method iterates over the permit list and prints each name separated by commas.
04:12
So after printing the permutation a new line is added...