1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aev [14]
3 years ago
14

Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will rea

d a list of one word names, then use a recursive method to create and output all possible orderings of those names, one ordering per line.
Computers and Technology
1 answer:
irinina [24]3 years ago
3 0

Answer:

Check the explanation

Explanation:

Executable Code:

def all_permutations(permList, nameList):

   # Define the function to create a list

   # of all the permutations.

   def createPermutationsList(nameList):

       # Compute and store the length of the list.

       n = len(nameList)

       # Return an empty list if the size is 0.

       if n == 0:

           return []

       # Return the element if the size is 1.

       if n == 1:

           return [nameList]

       # Create an empty list to store the permutations.

       permList = []

       # Start the loop to traverse the list.

       for i in range(n):

           # Store the first element of the current list.

           first = nameList[i]

           # Compute the store the remaining list.

           remaining = nameList[:i] + nameList[i+1:]

           # Start the loop and call the function recursively

           # with the remaining list.

           for perm in createPermutationsList(remaining):

               # Append the element in the permutation list.

               permList.append([first] + perm)

       # Return the permutation list.

       return permList

   # Call the function to compute the permutation list

   # and store the result.

   permList = createPermutationsList(nameList)

   # Start the loop to display the values.

   for perm in permList:

       for val in perm:

           print(val, end = " ")

       print()

# Call the main() function.

if __name__ == "__main__":

   # Prompt the user to enter the input.

   nameList = input().split(' ')

   permList = []

   # Call the function to create and output

   # the permutations of the list.

   all_permutations(permList, nameList)

#endcode

You might be interested in
What should every Software Engineer know about Software Architecture?
Alenkinab [10]
<span>!UML (all of them)
2.Flowchart (more for understanding a real world process of some kind; like a business process)
3.Data model including Bachman (if you don't need to at least understand your data, how it is stored versus a model, i.e., Bachman then you are doing it wrong and your schema could be simplistic)
This is 3 different examples</span>
6 0
3 years ago
The Mishiba Huya LED bulbs enable consumers to control lighting in their homes using a smartphone or tablet. When connected to a
kupik [55]

Answer:

may be it is integration

Explanation:

4 0
3 years ago
Assume inputFile is a Scanner object used to read data from a text file that contains a number of lines. Each line contains an a
anzhelika [568]

Answer:

words.hasNext()

Explanation:

Given the code snippet below:

  1.        while (inputFile.hasNextLine()) {
  2.            String word = "";
  3.            String line = inputFile.nextLine();
  4.            Scanner words = new Scanner(line);
  5.            while (words.hasNext()) {
  6.                word = words.next();
  7.            }
  8.            System.out.println(word); }
  9.    }

We have a inputFile Scanner object that can read data from a text file and we presume the inputFile has read several rows of data from the text file. So long as there is another line of input data available, the outer while loop will keep running. In each outer loop, one line of data will be read and assign to line variable (Line 3). Next, there is another Scanner object, words, which will take the current line of data as input. To get the last word of that line, we can use hasNext() method. This method will always return true if there is another tokens in its input. So the inner while loop will keep running so long as there is a token in current line of data and assign the current token to word variable. The word will hold the last token of current line of data upon exit from the inner loop. Then we can print the output (Line 8) which is the last word of the current line of data.

7 0
3 years ago
Brief deacription of how hard drives have evolved
Zepler [3.9K]

Answer:

The first HDD was created by IBM in 1956 and was the size of a refrigerator. The total storage capacity was 5 MB and only two heads were used to read the disks. The 1970s offered a hard disk drive in much smaller shells with the ability to store roughly 60 MB.

Please Mark Brainliest If This Helped!

4 0
2 years ago
What is the purpose of the operating systems management function
PIT_PIT [208]
The purpose of the operating systems is to provide an interface between the user and hardware. It's mange all resources, for example; memory, processors, and disk space. It's also mange how to file and store data in a computer system.
3 0
3 years ago
Other questions:
  • Semiconductor memory is used mainly for primary storage even with its high cost. In another hand, the magnetic tape is the cheap
    6·1 answer
  • How does information technology most benefit people’s personal and professional lives?
    9·2 answers
  • A blank is a link on a web page that leads to another web page.
    14·1 answer
  • Why might it be a good idea to choose a bus topology?
    6·2 answers
  • Jake was working on an essay for his English class on a stormy Sunday afternoon. Before he could save his document, a big strike
    8·1 answer
  • Project: Math Tutor Program with Error Handling
    9·2 answers
  • What is 2D thinking and 3D thinking? i literally don't understand
    6·1 answer
  • National ISPs usually offer fewer services and have a smaller technical support staff than regional ISPs.
    13·1 answer
  • Alice recently purchased a new cell phone. After her vacation, Alice wanted to transfer her holiday photos to her computer to do
    8·1 answer
  • What are the characteristics of computer. Explain any one​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!