Posts

Showing posts from January, 2019

Minimum Spanning Trees (MST)

Image
Let's imagine an undirected graph with weighted edges. From this graph, the spanning tree wil be a tree that maps all the vertices. In other words, the tree seen above will be G = (V, E) = (4, 5) and the spanning tree must be at least S = (4, 3). Let us visualize us this down below. Here we will have S = (4, 3) marked with green, which will be our spanning tree. As we can see, it covers all the vertices in the tree. However, it doesn't cover all the vertices in regards to the weighted edges. This S tree will have the sum of 4 + 5 + 2 = 11. Now when it comes to minimal spanning trees, we have to care about the weighted edges in the graph. Let's find the minimal spanning tree of the G graph above. Let's call this subgraph for S2 = (4, 3). In this subgraph we will see that the sum will be equal to 4 + 1 +2 = 7 and that it covers all the vertices. Since it has the smallest sum out of all the spanning trees you can make over graph G, it will be the minimal sp

Walkthrough of red-black trees with example

Image
First of all, red-black trees are only a representation of 2-4 trees. The reason for this is because the red-black trees are easier to implement into code. We're not going to look at implementing red-black trees into code in this post, but rather some of the theory behind red-black trees. For red-black trees there's some rules. A node is either red or black A new node is always red Root node or leaves are always black A red node can not have a red parent or a red child Every path from the root to a nullptr node will have the same number of black nodes If the aunt is red, the father is red, and the daughter is red. Then what we must do is a color change. Where the aunt and father shall be black and the grandparent shall be red As an example, we can look at how we will build a red-black tree for the list 1, 2, 3, 4, 5, 6.

Double linked list with C++

Image
The structure of a node in a double linked list is almost identical to that of a single linked list . The only difference is that the node in a double linked list will have an extra pointer. This can visually be seen a:

A simple Android app - "How fast can you click" game

Image
Looking for some fun I created a very basic Android app that checks how fast you can click. The concept is simple, you have 30 seconds to click as fast as possible. The clicks will register and eventually tell you the overall clicks after the 30 seconds have run out. Once it's done you'll also have an option to refresh the game; giving a possibility to try to do better next time. Here's a picture from the Android Studio Phone Emulator.