Question
#include <string>
#include <iostream>
using namespace std;
void string_permutation( string& orig, string& perm )
{
if (orig.empty())
{
cout<<perm<<endl;
return;
}
for (int i = 0; i < orig.size(); ++i)
{
string orig2 = orig;
orig2.erase(i, 1);
string perm2 = perm;
perm2 += orig.at(i);
string_permutation(orig2, perm2);
}
}
int main()
{
string orig = "ter";
string perm;
string_permutation(orig, perm);
return 0;
}
a.
ter
b.
ert
c.
ret
d.
returns all the combination of ter
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. What is the header file for vector permutation?
View solution
Q. How many parameters are required for next_permutation?
View solution
Q. Pick out the in correct type of function in header file.
View solution
Q. What type of algorithm is not available in creating our own STL style algorithms?
View solution
Q. What is meant by hash tables in C++?
View solution
Q. What is the use of includes function in c++?
View solution
Q. How many parameters are required for sort_heap function?
View solution
Q. How many categories of iterators are there in c++?
View solution
Q. Which of the following can serve as random-access iterator?
View solution
Q. What kind of pattern is iterator pattern?
View solution
Q. In which type of semantics does c++ implements iterator?
View solution
Q. By using which operator does point to next element is represent in
View solution
Q. What is the use of checked iterators?
View solution
Q. What will happen if the iterator is unchecked?
View solution
Q. How many adaptors support the checked iterators?
View solution
Q. What does the checked iterator allow you to find?
View solution
Q. What kind of errors do checked iterators detect?
View solution
Q. Where are allocators used?
View solution
Q. Where are allocators implemented?
View solution
Q. Which operator is used to allocate the memory?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!