The coolest programming algorithms for beginners, explained humanly (Part 1)

Recursion

The main definition is “to contain it self” . In 1904, an  advert image showed a woman who held a cacao pack with exactly the same image of her on the packet. Of course, in photography and graphics this effect has been used multiple times, but also in mathematics and computer science.

Binary search

In a very few words, it means, searching an element from a list dividing that list in 2 parts. If is less than the middle item, than it will look in the first part, dividing again that list. The guide of binary search is to compare elements till it finds the one that equals to what we are searching for.

For example looking for "4", having the elements above. First, it compares 4 with 7 and decide that 7 bigger, so it start looking for 4 in the first part. Then, it divides again the left part of the array in 2, and compare with the middle item.

FIFO/LIFO

It is about the elements that are added and/or removed in a list.

FIFO-First in, First out(Queue)
it is like the line of supermarket: first who sits in the line buys the products.

LIFO- Last in, First out(Stack)- the most common usage can be seen at Back Button, for example in a browser: the ultimate page/action you’ve seen/done is the first one who show up. In the example with books, naturally the first one we pick is the last one added.