Examples of single and multi-threaded algorithms with incremental optimizations