Write a program to print all permutations of string?
Answer / Md Hasan Ahmad
Here is an example implementation using recursion:n```javanvoid printPermutations(String str, int l, int r) {n if (l == r) {n System.out.println(str);n return;n }n for (int i = l; i <= r; i++) {n str = swap(str, l, i);n printPermutations(str, l+1, r);n str = swap(str, l, i);n }n}nString swap(String str, int i, int j) {n char temp; temp = str.charAt(i);n str = str.substring(0, i) + str.substring(j, i) + str.substring(j+1, i+1) + str.substring(0, j);n return str;n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
How do I write a self declaration?
What is java and why do we need it? Explain
What are data types in programming?
how to create multithreaded program? Explain different ways of using thread? : Java thread
Explain the difference between a Thread and a Process.
What is structure of java heap? What is perm gen space in heap?
What are computer functions?
Can we call the constructor of a class more than once for an object?
How will you get the platform dependent values like line separator, path separator, etc., ?
What is string in java? String is a data type?
Convert Binary tree to linked list.
What code optimizations techniques you follow in general practice?
2 Answers Accenture, TCS, Wipro,