Tagged: Algorithms

Generic Factory in C++ 0

Generic Factory in C++

A generic factory is a factory that can register any class type. It is very easy to write because we are allowed to use void pointers.

Usage:

As we are simply casting a void pointer, it is left to the developer to ensure the right class type is...

Maximum Subarray 0

Maximum Subarray

Problem statement: Find the largest sum that is possible in an array. I.e., find the maximum sub-array. Solution: From the very first this problem looks complicated because of how it is framed. It sounds like we want to find the MAXIMUM from ALL THE POSSIBLE sums. To find the maximum...

Sorting for humans 0

Sorting for humans

If you are anything like me, you have at least once in your life tried to sort all the cards in a deck. Which sorting algorithm did you use? Well, humans generally use Insertion sort without even thinking. But the interesting part is that insertion sort actually works really really...