lunedì 13 aprile 2020

Pythagorean Tree

At the very begins of the programming learning journey, one will likely get stuck in a crucial concept: recursion.
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)





Knapsack Problem

This is a great classic of algorithm problems.
This problem requires finding a proficient way to select some objects with a certain value among many others. In order to put in the set as much total value as possible considering a maximum space allowed.
I resolved this problem with a brute force algorithm and a branch and bound one.
I then wrote both the pseudo-code and the python code in a pdf file that you can find in my repository here https://github.com/AndreaRubbi/Knapsack-implementation-Python/blob/master/Knapsack.pdf
The most efficient way of resolving this problem is, however, using a dynamic algorithm.
Yet, I didn't implement it so far. If anyone would like to see it, I could do it 'on-demand' let's say.
Hope you'll enjoy!

WELCOME

-- WELCOME --
I am Andrea Rubbi, a Genomics student and non-professional programmer.
I started programming in 2017 and since then I encountered many obstacles and difficulties.
This Blog is mainly a way to give back to the NET all the support I have received in these years and to help those in need.
Since I started programming I realized one thing: there is no progress without co-operation.
My motto is 'Precise, Pragmatic, Proficient', I hope you'll find my posts worthy of it.
Many Thanks.
RA
PS: All the material is also available in my Github repositories