Showing segmentation error

@aryaman.kumar26 im looking into it, wait

@aryaman.kumar26 you have to do nothing in the base case, do all the work in the recursive case only. Also the base case should be at n == 0. (no more rods to shift)
https://ide.codingblocks.com/s/269660 this is the corrected code.

Dont forget to mark your doubt as resolved

unable to understand your answer…can you simplify please

@aryaman.kumar26 ive just now posted it, please look at it once

yeah i know that but why can’t i do by this approach

i was also wondering by this method we will be unable to print n like which number of rings are we shifting…right?

@aryaman.kumar26

i am not following you… if you are talking about the approach i gave it will work perfectly well, you can even find number of steps required. The approach you gave is wrong because you cant shift rods in base case only, work needs to be done at each point, If you have any confusion just do a dry run of it

OUTPUT SHOULD BE-moving (ring number) from source to destination
so in the previous reply i was saying that through my approach we might not be able to find the number of the ring that we are shifting…right?

@aryaman.kumar26 but that is the whole purpose of the question. What exactly will that approach be able to tell us?

if we talk about your recent reply like we have already shifted n-1 rings and then when we only have one we print the shifting…why is this not correct

@aryaman.kumar26 you are saying we have already shifted n-1 rings, how will you do that without doing any work in the recursive case? Current case has to be considered in the recursive part, not in the base case part.

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.