Question

Write a recursive method to return all possible k permutations of the given String non-zeros number...

Write a recursive method to return all possible k permutations of the given String non-zeros number

Sample input : "123" , 2

output : "1-2", "1-3", "2-3", "2-1", "3-1", "3-2"

** Please provide

-PSEUDO CODE

-UML DIAGRAM

Homework Answers

Answer #1

Sol.

Here is recursive algorithm puesdo code for permutation the string.
permutation(string s)
   if string is empty then return
   for i=0 to str.length()
       store char in variable a from index i from string s
       string p = str.substring(0 to i) + str.substring(i+1)
       string x;
       call the recursive fuction permutation(p, x+a)
return x to main fuction

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please code in Java Write a recursive method that takes a string and return a string...
Please code in Java Write a recursive method that takes a string and return a string where every character appears twice. For example, if the string is “HELLO”, it will return “HHEELLOO”. Write a program to test it.
Write a recursive function block_count(string) to return the number of blocks consisting of the same letter...
Write a recursive function block_count(string) to return the number of blocks consisting of the same letter in the given input string. Example. >>> block_count ('AABBCCBBDDD') 5 >>>block_count ('GGABAA') 4
Question 2. Consider a recursive method that removes all occurrences of substring in a given string...
Question 2. Consider a recursive method that removes all occurrences of substring in a given string Examples: Input1 : str=‘abcccabc’, substr= ‘abc’, result1: ‘cc’ Input2 : str=‘aabcbcc’, substr= ‘abc’, result2: ‘abcc’ Input3 : str=‘bacbcbcc’, substr= ‘ab’, result3: ‘bacbcbcc’ Write a complete pseudo code/algorithm to solve the requirement of the method as explained above. (15 points) Note: write the information that you need to describe the header of the method Trace your algorithm using input1. (5 points)
Write a recursive method repeatNTimes(String s, int n) that accepts a String and an integer as...
Write a recursive method repeatNTimes(String s, int n) that accepts a String and an integer as two parameters and returns a string that is concatenated together n times. (For example, repeatNTimes ("hello", 3) returns "hellohellohello") Write a driver program that calls this method from the Main program. Program should ask for input and be stored in the string and should return n amount of times.
C++ Write a recursive function that reverses the given input string. No loops allowed, only use...
C++ Write a recursive function that reverses the given input string. No loops allowed, only use recursive functions. Do not add more or change the parameters to the original function. Do not change the main program. I had asked this before but the solution I was given did not work. #include #include using namespace std; void reverse(string &str) { /*Code needed*/ } int main() {    string name = "sammy";    reverse(name);    cout << name << endl; //should display...
C+ VISUAL STUDIO.. SHOW OUTPUT PLEASE Write a program that computes the number of possible combinations...
C+ VISUAL STUDIO.. SHOW OUTPUT PLEASE Write a program that computes the number of possible combinations to obtain a successful result of an arbitrary event. The formula for computing the possible combinations is given by: C(n,k)= n! / [k! * (n - k)!] where, n = the number of events k = number of success for that event Use the recursive function factorial explained in the chapter to compute the possible combinations.  The output should be displayed as follows: C( n,...
Write recursive method to return true if a given array of integers, named numbers, with n...
Write recursive method to return true if a given array of integers, named numbers, with n occupied positions is sorted in ascending (increasing) order, or returns false otherwise. Array can be empty or not. //PRECONDITION: Varible n denotes the number of occupied positions in the array and must be non-negative. Employee class has method getSalary() that returns employee's salary. // An empty array and an array with single element in it, are sorted. Method isSortedRec must be recursive and returns...
C++ code Please: 1. Write a function to find the first occurrence of a given letter...
C++ code Please: 1. Write a function to find the first occurrence of a given letter in a string, return the index. If not found, return -1. (2’) Input example: str = "Hello World!" find(str, 'e') Input example: str = "a random string" find(str, '3') Output example: 1 Output example: -1
Given a binary string of zeros (0) and ones (1). You have to build a circuit...
Given a binary string of zeros (0) and ones (1). You have to build a circuit that counts the number of occurrences of string '01' within the given string. For example, given string '01000110001001', there are 4 occurrences of '01' and output have to show number of occurance each time '01' occured. Use a FSM and a counter (built from D flip-flops) to implement this circuit. It is guaranteed that the number of occurrences is not more than 31 (you...
IN JAVA: Write recursive method to return true if a given array has element equal to...
IN JAVA: Write recursive method to return true if a given array has element equal to employee emp, or returns false otherwise. Array can be empty or not. //PRECONDITION: Varible n denotes the number of occupied positions in the array and must be non-negative. Employee class has method getSalary() that returns employee's salary, // and it has method boolean equals(Employee emp) that accept an employee object and returns true if employee calling the equals method is equal as employee emp,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT