Computer Engineer + iOS Engineer. I am interested in Swift, Kotlin, Firebase, Data Structures, ASO & On Solving Real World Problems.

**Clubhouse** shortly became one of the most popular apps on the AppStore. I would say there's many reasons for the social network growth, one of them, no doubt, is their easy to use interface. Not only easy to use, but also sophisticated and beautiful.

Once in a while I like to review some sorting algorithms, the same with data structures. This week I was reviewing the merge sort.

I followed some tutorials to remind me. You can follow one of them here: https://www.raywenderlich.com/741-swift-algorithm-club-swift-merge-sort

One thing that bothered me is the space necessary for this algorithm to work. Basically we create copies of the list, till we have a list with only one element.

I proposed myself a challenge of writing this in-place. I have no doubt there are some algorithms doing something similar out there, but I just did want to have fun.

As…

Today, we will talk about how to create an implementation based on event listeners. This implementation will be retain-cycle-free. I will also give a brief description of how event listeners work and why we have to care about retain cycles when implementing them.

Sometimes, you want to notify one or more objects that an event has occurred. For example, it could be the fact that the user has logged out or logged into the app. This kind of thing can be easily done by using delegates. One object implements a protocol and becomes a "listener" of the user auth state…

I was really interested on this problem of sorting elements. Sorting with heapsort is fast! But it has a big problem: conventionally you have to build a heap to use a heap sort. In a real world usually you don't have a heap mounted to sort whenever. I just imagined that we could create a heapsort inplace, and instead of dealing with heaps objects, we could still have our simple array, and only transform it in a heap when needed.

First of all, I hope you understand what is a heap, and how the heapsort works. If not, I wrote…

I started to play with *VIPER* around 2 years ago. At first it was a little confusing what each element of that architecture was responsible for. And in fact distribute responsibilities is one of the main keys of VIPER. This post brings a little of my thoughts around the responsibilities of the ** View**. Also, I decided to expose some practical questions, which means applying

According to a post co-written by Jeff Gilbert, the creator of *VIPER*, *the View (1) is the component that…*

I hope you can take a look at my previous piece on heaps, “Let’s Learn About Heaps in Swift,” since heaps are at the heart of this algorithm.

Today we'll discuss a little about the sorting algorithm called *heapsort*. It was introduced in the 60s and is still one of the most powerful structures to order numbers, strings, etc. The same guy who introduced the heap also proposed the heapsort, so it's like they're both intrinsically interrelated. And we'll see why.

There's no heapsort without the heap. The idea of the heap is to have a structure where the first…

In general, heaps are interesting structures for computer science. They sound and look like trees. Usually, the implementation of these guys is made using an array with some helper functions.

I was studying these structures and decided to implement them using Swift. I will be using *Introduction to Algorithms* by Thomas Cormen as a guide. The book uses the index *1* as the first index of a list. In order to make our implementation work smoothly, I will be replacing it with *0*. Let's go to the implementation.

So basically, as mentioned in *Introduction to Algorithms*, the implementation of this…

I was solving this problem a couple days ago and I decided to post it here, so maybe I can help someone facing something similar.

Basically given a two dimensions matrix of numbers, we have to sum the value of the neighbors of an also given index. The index will be constituted of a line and column. Let's see an example of matrix that could be used in our algorithm.

Today I was presented to this problem. Basically given a list of elements, I’d have to find the nearest distance between two elements of that list.

You can see an example of given list. Notice that we’re not talking about a set, which means that elements could possibly repeat.

Let’s go through some possible situations and answers for these situations.

Ok so let’s go to the algorithm. First of all we’re going to create a class wrapper to contain our information. We can call it `NearestIndexFinder`

. The initializer of this class will receive the array of elements. Here’s…

I was curious about some data structures, and the hash table is one of them. I was wondering how I could implement one of these guys using Swift.

They're really powerful data structures when well implemented. Basically their insertion and fetch are made in constant time — **O(1)** if well implemented. The worst case scenario is **O(n)** for both actions.