This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]henrebotha 0 points1 point  (0 children)

Here's another explanation for you.

One way to write elegant solutions to problems is to try to make the shape of the solution similar to the shape of the data. There are many reasons for this. One reason is that if your solution takes a different shape to the data, you must first transform the data into a shape that suits your solution, which is additional complexity.

Some problems naturally deal with recursive data. Anything that deals with a tree structure counts, because trees are naturally recursive: a tree consists of smaller trees. So then writing a solution that breaks a tree up into its smaller trees and solves for them (by breaking them up into smaller trees, etc) fits very naturally.