The solution is the recursive Python 3 function below:
########################################################
def allNamePermutations(listOfNames):
# return all possible permutations of listOfNames
if len(listOfNames) == 0 or len(listOfNames) == 1:
# base case
return [listOfNames]
else:
# recursive step
result_list = [ ]
remaining_items = [ ]
for firstName in listOfNames:
remaining_items = [otherName for otherName in listOfNames if
(otherName != firstName)]
result_list += concat(firstName,
allNamePermutations(remaining_items))
return result_list
#######################################################
How does the above function work?
As with all recursive functions, this one also has a base case, and a recursive step. The base case tests to make sure the function terminates. Then, it directly returns a fixed value. It does not make a recursive call.
In the case of this function, the base case checked listOfNames to see if it was empty or only had one name. If any of the conditions were satisfied, a new list containing listOfNames is returned.
The recursive step is where the function allNamePermutations() calls itself recursively. The recursive step handles the case where listOfNames has more than one item. This step first iterates over each name in listOfNames, and then does the following;
Gets a name in listOfNameGets a list of other names in listOfNamesCalls allNamePermutations() on the list of other names to get a list of permutation of the other names.(By first getting the list of other names before passing it into
allNamePermutations(), we make sure the recursive step eventually
terminates. This is because we are passing a smaller list each time
we make the recursive call.)
Inserts the current name in front of each permutationAdds the results to the result list to be returned laterAfter the iteration, it returns the result list which will now contain all permutations of the names in the list.
The concat function is defined below
##################################################
def concat(name, listOfNameLists):
# insert name in front of every list in listOfNameLists
result_list = [ ]
for nameList in listOfNameLists:
nameList.insert(0, name)
result_list.append(nameList)
return result_list
#####################################################
If we run the sample test case below
####################################
name_list = ['Adam', 'Barbara', 'Celine']
allNamePermutations(name_list)
####################################
the following output is produced
[['Adam', 'Barbara', 'Celine'],
['Adam', 'Celine', 'Barbara'],
['Barbara', 'Adam', 'Celine'],
['Barbara', 'Celine', 'Adam'],
['Celine', 'Adam', 'Barbara'],
['Celine', 'Barbara', 'Adam']]
For another example of how to use recursion in Python, see the following example in the link below
https://brainly.com/question/17229221
what are the main barriers to the adoption of an industry standard for internet system
Answer:
Industry experts say that although many companies find the potential of the Internet of Things very attractive, they either lack a clear value proposition for end-users or lack interoperability.
Without proper synchronization, which is possible, a deadlock, corrupted data, neither or both? Give reasons for your answer.
need answer pls
Without proper synchronization, corrupted data is possible due to the fact that a shared datum can be accessible by multiple processes.
Data synchronization simply means the idea of keeping multiple copies of dataset in coherence with one another in order to maintain data integrity. It's the process of having the same data in two or more locations.
Without proper synchronization, corrupted data is possible because a shared datum could be accessed by multiple processes without mutual exclusive access.
Read related link on:
https://brainly.com/question/25640052
Write a program, using case statements, that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. For division, of the denominator is zero, output an appropriate message.
Answer:#include<iostream>
using namespace std;
int main() {
int var1, var2;
char operation;
cout << "Enter the first number : ";
cin >> var1;
cout << endl;
cout <<"Enter the operation to be perfomed : ";
cin >> operation;
cout << endl;
cout << "Enter the second nuber : ";
cin >> var2;
cout << endl;
bool right_input = false;
if (operation == '+') {
cout << var1 << " " << operation << " " << var2 << " = " << (var1 + var2);
right_input = true;
}
if (operation == '-') {
cout << var1 << " " << operation << " " << var2 << " = " << (var1 - var2);
right_input = true;
}
if (operation == '*') {
cout << var1 << " " << operation << " " << var2 << " = " << (var1 * var2);
right_input = true;
}
if (operation == '/' && var2 != 0) {
cout << var1 << " " << operation << " " << var2 << " = " << (var1 - var2);
right_input = true;
}
if (operation == '/' && var2 == 0) {
cout << "Error. Division by zero.";
right_input = true;
}
if (!right_input) {
cout << var1 << " " << operation << " " << var2 << " = " << "Error;";
cout << "Invalid Operation!";
}
cout << endl;
system("pause");
return 0;
}
Explanation:
Consider the conditions and intentions behind the creation of the internet—that it was initially created as a tool for academics and federal problem-solvers. How might that explain some of the security vulnerabilities present in the “cloud” today?
It should be noted that the intention for the creation of the internet was simply for resources sharing.
The motivation behind the creation of the internet was for resources sharing. This was created as a tool for academics and federal problem-solvers.
It transpired as it wasn't for its original purpose anymore. Its users employed it for communication with each other. They sent files and softwares over the internet. This led to the security vulnerabilities that can be seen today.
Learn more about the internet on:
https://brainly.com/question/2780939
Question # 1 Multiple Select Which features are important when you plan a program? Select 4 options. Knowing what information is needed to find the result. Knowing what information is needed to find the result. Knowing what the user needs the program to accomplish. Knowing what the user needs the program to accomplish. Knowing how many lines of code you are allowed to use. Knowing how many lines of code you are allowed to use. Knowing what you want the program to do. Knowing what you want the program to do. Knowing how to find the result needed. Knowing how to find the result needed.
What type of database replication relies on centralized control that determines when replicas may be created and how they are synchronized with the master copy
Database replication is very common in this Era. Traditional database replication is relies on centralized control that determines when replicas may be created and how they are synchronized with the master copy.
Database replication is known to be the constant electronic copying of data from a database using one computer or server that is connected also to a database in another . this ensure that all users do share the same level of information.
Replication is often done to technologies which are used for copying and distributing data and database objects from one database to another and thereafter use in synchronizing between databases.
Conclusively, Replicas can only be made in the Traditional database replication through the power of centralized control.
See full question below
What type of database replication relies on centralized control that determines when replicas may be created and how they are synchronized with the master copy?
a distributed database model
b. traditional database replication
c. enterprise replication
d. local database model
Learn more about database replication from
https://brainly.com/question/6447559
The capability of moving a completed programming solution easily from one type of computer to another is known as ________. Group of answer choices
Answer: Portability
Explanation: I hope it helps you!
If ClassC is derived from ClassB which is derived from ClassA, this would be an example of ________.
Answer:
Inheritance
Explanation:
a leading global vendor Of computer software hardware for computer mobile and gaming systems and cloud services it's corporate headquarters is located in Redmond Washington and it has offices in more then 60 countries
Which One Is It
A) Apple
B) Microsoft
C) IBM
D) Global Impact
Answer:
B
Explanation:
They have offices in Redmond Washington
Which of the following is NOT a function of a Web Browser?
O Provide a platform that users can use to access web pages and sites
O Access a Web server and request a page on the Internet so the right information shows up
O Crawl through the World Wide Web searching for words and terms to index in Web Databases
O Interpret Web page's HTML tags and display the Web page's information in a way that is intended/easily readable for you
A web browser is used to gain access to the contents of a website, displaying the information in a readable and easily understandable format. Hence, an option which isn't a function of a web browser is Crawl through the World Wide Web searching for words and terms to index in Web Databases
A web browsers allows users to access web pages and sites, by accessing web servers and requesting access to display the contents. Web pages are written in Hypertext Markup Language (HTML). Browsers interpret these document format and tags so that it is displayed in an understandable format.Learn more : https://brainly.com/question/17130932