Studying one algorithm per day for 30 days to strengthen my programming skills.
I got my university degree in graphic design. I didn't start coding until I was 28. I do not have a background in computer science, and I've always felt self-conscious about that. Until recently, it had never directly impacted my career.
I recently did not make it past a first-round coding challenge because my code was "too complex". I went online to see if I could find evidence to prove the reviewer wrong. What I discovered very quickly is, "SHE WAS RIGHT". I was really hurt and disappointed in myself, but I am not one to navel-gaze for long. I decided to see it as a challenge and learning experience.
To strengthen my understanding of the most common and most useful algorithms, I decided to pick one algorithm every day for 30 days and learn how to use it effectively and to commit it to memory.
Life being what it is - which is to say unpredictable and hectic - I may not post an alogirthm every single day, but I will post one "for" every day. For instance, today I am posting the first 3 days. Some days I may not have time to post one but I will make up for any missed days.
I will not only add each algorithm here but will post each one as a public gist. feel free to join the discussion on the gists.
Euclid's Algorithm for finding the greatest common divisor of two positive integers.
Algorithm to find the missing number given an array of positive integers from 1 - N, with no duplicates and only one missing number.
Bubble sort has a worst-case and average complexity of О(n2), where n is the number of items being sorted. Even though it is not the most efficient algorithm, it is worth knowing how to do.
Efficient algorithm to find the intersection of two lists. This is a common coding test problem but also a common problem to encounter in real-world apps.
This is a very elegant solution by Philip Stanislaus that converts a flat array into a tree in O(n) time. It works in a single pass. Look, ma. No Recursion !!! :-)
Although it is not the most efficient sorting algorithm, Merge Sort is good to know and is fairly easy to implement.
Quicksort is one of the most efficient sorting algorithm with O(log n) Big-O notation. It can be 2x - 3x faster than merge sort. This article by César Antón Dorantes does a great job explaining how it works.
Binary search is a divide-and-conquer algorith. Start with a sorted list, work from the ends, split the list in half, and determine which half to discard.