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
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...
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...
Describe recursive algorithms for the following variants of the text segmentation problem. Assume that you have...
Describe recursive algorithms for the following variants of the text segmentation problem. Assume that you have a subroutine IsWord that takes an array of characters as input and returns True if and only if that string is a “word”. (a) Given an array A[1 .. n] of characters, compute the number of partitions of A into words. For example, given the string ARTISTOIL, your algorithm should return 2, for the partitions ARTIST·OIL and ART·IS·TOIL. Do this by appropriately modifying the...
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,...
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...
Write a recursive method body for the method whose contract is given below. Note that n...
Write a recursive method body for the method whose contract is given below. Note that n is a restores-mode parameter. As an example, if n = 314, the method should return 1. You can only use the NaturalNumber kernel methods multiplyBy10, divideBy10, and isZero. /** * Reports the minimum (i.e., smallest) digit of n when it is * written in ordinary decimal notation. * ... * @ensures * minDigit = [the minimum digit of n] */ private static int minDigit(NaturalNumber...