Q157
What will be the time complexity of the given code? #include #include #include using namespace std; void swap(char *x, char *y) char temp; temp = *x; *x = *y; *y = temp; void func(char *a, int l, int r) int i; if (l == r) cout<<a<<” ,”; else for (i = l; i <= r; i++) swap((a+l), (a+i)); func(a, l+1, r); swap((a+l), (a+i)); int main() char str[] = "AB"; int n = strlen(str); func(str, 0, n-1); return 0;
A.
O(n2)
B.
O(n * n!)
AnswerC.
O(n!)
D.
O(n log n)
Answer: Option B
Solution
Answer: Option B
No explanation is given for this question Let's Discuss on Board