Monthly Archives: February 2020

Boyer-Moore Majority Vote Algorithm

If we need to find a number that appears in more than half of the elements in an array, we can do so in O(n) time and O(1) space using the Boyer-Moore majority vote algorithm. We use a variable to … Continue reading

Posted in programming | Tagged , | Leave a comment

Smart pointers

Disclaimer: This is post is just showing example smart pointer implementations for illustrative purposes. In production code I would recommend using the standard library unique_ptr and shared_ptr instead. A basic smart pointer will wrap a pointer, so the object gets … Continue reading

Posted in programming | Tagged , | Leave a comment