Graph Traversals in C++

Graph traversals in the form of Depth-First-Search (DFS) and Breadth-First-Search (BFS) are one of the most fundamental algorithms in computer science. As the use of these algorithms plays an essential role in tasks such as cycle-detecting , path-finding , and topological … | Continue reading


@inversepalindrome.com | 4 years ago

How to Generate Permutations of a String in C++

Generating all possible permutations of a set of elements is generally done by using recursive methods. Therefore, to generate the permutations of a string we are going to use backtracking as a way to incrementally build a permutation and stop as soon as we have used every poss … | Continue reading


@inversepalindrome.com | 4 years ago

How to Binary Search in C++

Binary Search is a very useful algorithm whenever we are dealing with an already sorted group of elements. If we take a look at the C++ STL we find a function called std::binary_search that implements this algorithm but upon further research, we learn that it only tells us if t … | Continue reading


@inversepalindrome.com | 4 years ago

How to Find the Kth Largest Element in an Array

The most obvious way to find the Kth largest element in an array would be to sort the array in descending order and then access its element at the index k - 1. However, the shortcoming of this approach comes from the fact that it doesn’t solve this problem in the most optimal w … | Continue reading


@inversepalindrome.com | 4 years ago

How to Iteratively Traverse a Binary Tree

Binary tree traversals are generally done in a recursive manner because this type of problem tends to be simplified by such methods. Nevertheless, the key advantage gained by using an iterative approach is the fact that the traversal will not run out of stack space. Moreover, the … | Continue reading


@inversepalindrome.com | 4 years ago

How to Format a String in C++

String formatting is a common and useful operation that is regularly used in most programming languages. Unfortunately, the formatting solution offered in the C++ Standard Library lacks simplicity and intuitiveness. For that reason, implementing a C-style “ printf ” type function … | Continue reading


@inversepalindrome.com | 4 years ago

How to Create a Random String in C++ (Blog Post)

Generating a random string in C++ is a simple task that can be easily achieved by the use of rand() ; however, this method is not recommended because rand() lacks a distribution engine and the quality of its implementation leaves more to be desired. To combat this issue, the C++ … | Continue reading


@inversepalindrome.com | 4 years ago

How to Split a String in C++ (Blog Post)

Splitting a string seems like a basic function that any language should have out of the box. Yet, C++ doesn’t provide an in-built method in the standard library that takes care of this task. The reason for the absence of this feature is likely due to the fact that the algorithm h … | Continue reading


@inversepalindrome.com | 4 years ago

C++ the Spaceship Operator and Class Types in Non-Type Template Parameters

Game and Application Development | Continue reading


@inversepalindrome.com | 5 years ago

DynaMix: An Alternative for Polymorphism

Polymorphism in C++ has usually been implemented through the use of an inheritance hierarchy and virtual function calls. This method while effective has one key drawback originating from the problem of multiple inheritance: a derived class having two or more parents can be … | Continue reading


@inversepalindrome.com | 5 years ago