Please tell with steps the solution
Question
What will be the output for the following pseudocode if the parameters have the following values:list[] = {'a', 'b', 'c'}, i = 0 and n = 2
void SWAP(char list[], int i, int j)
char t=list[i]
list[i]=list[j]
list[j]=t
void func(char list[], int i, int n)
int j, temp
if(i==n)
for(j=0; j<=n; j++)
print (list[j])
print (" ")
else
for(j=i; j<=n; j++)
SWAP(list, i, j)
func(list, i+1, n)
SWAP(list, i, j)
Options
1. abc acb bca bac cab cba
2. abc acb bca bac cba cab
3. abc acb bac bca cab cba
4. abc acb bac bca cba cab
Answers
Answered by
0
Answer:
abc acb bca bac cba cab
Explanation:
Answered by
0
Answer:
The code will swap the ARRAY.
Explanation:
list [] is an array of char containing 3 characters a,b,c.
The function "SWAP" is created which returns void or nothing
The SWAP function swaps the elements of array list [i] and list[j].
In the function "func"
when, i<n;
it will swap array elements and then increment the counter and then swaps the array.
#SPJ3
24 MAY 2022.
Similar questions