eyeglasses with black frames on white desk
Photo by Temple Cerulean on Unsplash

One of the first algorithms that we are usually taught is finding either the smallest or the largest element in a list of elements by iterating through every element in a list.

Let’s assume that we are trying to find the smallest element in a list.

The algorithm is quite straightforward and intuitive even for a 5-year-old: You assume that the first element is the smallest and save its value in a variable.

Continue reading