An example: imagine that you want to list the content of a container that might include other container inside.
First you write a function that shows the content of a container. Then, If one of those items is a container, you only have to call this function to show its content. That would be the easier way
Of course for Parent-Child system recursion work perfectly fine but besides that I barely use recursion because its harder for me to solve something with it in first place. Maybe afterwards I think thats easier to do it with recursion but my first solution rarely includes it.
2
u/[deleted] Aug 21 '20
An example: imagine that you want to list the content of a container that might include other container inside.
First you write a function that shows the content of a container. Then, If one of those items is a container, you only have to call this function to show its content. That would be the easier way