Please solve this querry
I don't get dry run of rec. Part of this problem
sample i/p
23
keypad[2] ={“ABC”}
keypad[3] ={“DEF”};
so basically first u use
i = 0 ;
int digit = str[i]-‘0’;
digit ->2
for(int k = 0 ;keypad[digit][k] != '\0'; k++){
out[j] = ch[digit][k];
keypad(str , i+1 , out , j+1);
}
so u ‘A’ then u increment i , j
now digit becomes
3 ( since j= 1)
u take the character at position 0 for keypad[3] ie D
AD is formed
then u increment i , j
i goes out of bound -> base case is hit
AD is printed
then return is encountered
now k = 1 ( digit = 3 , j = 1 )
AE is formed
(j = 2 , i = 2 ) base case AE is printed
now k = 2 ( digit = 3 j = 1)
AF is formed
now k = 3 ( digit = 3 , j = 1 ) -> keypad[digit][k] == ‘\0’
hence traces back
…
…
…
now digit = 2 k= 1 j =0
now B is added to out[0]
i+1 , j+1 is called
BD
BE
BF
printed
and so onnn
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.