Category Archives: C++

Longest Palindromic Substring

Problem Write a function that, given an input string, locates and returns the longest sequence in the string that is a palindrome. Solution Every sub-string starting from the longest to the shortest needs to checked as shown below is_palindrome can … Continue reading

Posted in Algorithm, C++, Software Puzzle | 2 Comments

On computing the checksum

Problem Marius Bancila [Bancila 2018](Chapter 8, Problem 69) describes a checksum computation problem which can be paraphrased as follows: Let X = x1x2…xN where xi is a decimal digit. X is a valid number if (Σi=0N (N-i)*xi) mod 10 = … Continue reading

Posted in Algorithm, C++, Software Puzzle | Leave a comment

Linq for C++

Motivation The benefits of SQL-like declarative syntax for imperative programming languages like C# is [well documented](www.tutorialsteacher.com/linq/why.linq) Linq as it is known in C# has been implemented by more than one team in C++. The main advantages are Improved Readablity Declarative … Continue reading

Posted in C++ | Leave a comment

Multiway Trees

“Rien n’est plus dangereux qu’une idée, quand on n’a qu’une idée.” Émile-Auguste Chartier Abstract In considering how to print a multiway tree in heirarchical fashion, this blog shows that there are many ways to represent a multiway tree in a … Continue reading

Posted in C++, Data Structure, Software Engineering | Tagged , , | Leave a comment

A quick note on all permutations

Marius Bancila [Bancila 2018] (Chapter 6, problem 52) poses the next permutation problem as follows: Write a function that, prints on the console all the possible permutations of a given string. and provides a recursive version of the solution as … Continue reading

Posted in Algorithm, C++ | Leave a comment

Semi-Stable Partition

Inspiration Alexander Stepanov and Paul McJones in the their book “Elements of Programming” (Chaper 11.1) describe a stable partition algorithm that appears to be more complex than necessary. Here I present an improvement. Problem Definition A partition of sequence with … Continue reading

Posted in Algorithm, C++ | Leave a comment

String Matching Algorithms

Simple algorithms for searching permutations and combinations in strings Continue reading

Posted in Algorithm, C++ | Leave a comment

On Computing the Fibonacci Number in O(log(n))

Introduction Liu Feng posted a number of Lisp functions to compute a Fibonacci number with O(log(n)) time complexity where n is the n-th number to be computed. The last such function involved tail recursion. While the function is correct there … Continue reading

Posted in Algorithm, C++ | 4 Comments

Unit Testing With Boost in Visual Studio

The Problem There are many Unit Testing Frameworks (UTF) for C++. Wikipedia list over 50 of them. Not all of them are created equal. CPPUnit is one of the oldest and is still popular. Google Test has a strong brand … Continue reading

Posted in C++, Software Engineering, Windows | Tagged | 5 Comments

Asio: A Brief Introduction for the Windows Programmer

Really! Yet another tutorial on Asio? “Why?” The average C++ programmer has much more experience than say the average Java/Javscript programmer – not necessarily a good thing. (C++ is becoming like assembler.) As such a C++ developer can understand how … Continue reading

Posted in C++, Concurrent Programming, Software Engineering | Tagged , , | Leave a comment