Recursion just means re-calling a function again and again from the function itself.
This is really important for normal programming problems, but it is ESSENTIAL when dealing with algorithms design.
The Pythagorean tree is one of the most tremendous ways to destroy the self-esteem of a programming freshman: most of the times the best obtainable outcome is something like:
which is already above the average result.
Yet, I have not explained in what, exactly, consists of the problem.
This tree should require as input a number 'n', which represents the number of levels of the tree.
The tree is composed of 2^n squares. The base-level n = 1 is thus a single square which has, on his top at level n=2, two squares, forming an isosceles triangle with them.
The aim is to continue this ramification until level n = n.
HINT : length = 180*((math.sqrt(2)/2)**depth)
Nessun commento:
Posta un commento