Symmetric and Asymmetric Cryptography a cursory glance

Goal of this blog post I will try to provide a basic overview of symmetric and asymmetric encryption and where one or the other would be used. Security is an interesting and important topic that will only gain more in importance with all the devices connected to the internet or some other network. Also I’m personally really interested in it but haven’t actually taken the time to start learning anything relevant beyond the most basic overview that I’ve snapped up from random sources. [Read More]

Making Recursive Functions Tail Recursive

First of this blog post assumes that you already have a basic understanding of recursion. I’ll use some Python for the code examples simply because it’s a popular language for learners, the concepts I’ll be talking about are language agnostic. In fact your preferred language might benefit more from tail recursion than Python. A look at a recursive factorial function Let’s first look at an issue with recursion, so that we can later fix it using tail recursion. [Read More]

What is recursion?

Recursion is a specific way to solve problems. It’s a pretty simple concept once you understand it, but regularly confuses people when they first learn it. In essence, when solving a problem, there often is a case that is simple to solve, a so-called base case. But many other cases that are complex and require a lot more computation. In recursion we make use of this. We look at the input, if we happen to have the simple case, we can go and return the easy solution. [Read More]

Don't exaggerate recursion overhead

A small pet peeve of mine is when people use the very naïve recursive implementation of the Fibonacci algorithm to show the overhead of recursion. Yes, recursion can have an overhead (depending on your environment), but it’s not nearly as much as you make it seem. The problem, The iterative version of the Fibonacci algorithm: def iterative_fibonacci(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return a has O(n) time complexity. [Read More]

String to integer conversions

There are various functions for converting strings to integers in the C++ standard library. This post is a small overview of these functions. I’ll start with the simplest and go to the more fully featured ones at the end. The atoi family. These functions coming from C represent the minimal set of functionality for a string to integer conversion. int atoi(const char *str); It only takes a single argument, a c-string and interprets it as a base-10 number. [Read More]

Floating point to integer conversion

This post serves mainly as a personal reminder and came up due to a question on The question was: How exactly does C++ casting between numeric types work? In my code, I do something like the following: double a = 3.0; uint64_t b = static_cast(a); double c = static_cast(b); Interestingly, this works as I would expect (a == c), as long as a is positive, but if a is negative, c ends up as an arbitrarily large positive number. [Read More]