ROIpad ← Back to Search
softwareengineering › answer

Answer to: How to choose between brute force and efficient solution that has overhead?

Score: 2
Answered: Sep 11, 2025
User Rep: 153
Eternal calibration This is a very lucky case where you can implement both and approximately always choose the best one. by simply running both in parallel in the first runs. Because the data is immutable and the computation has no side effects, running both at same time will not interfere in each one, besides wasting CPU time while the fast one still runs. After the fast one returns, setting up a flag in the other will interrupt the long lasting other. And by remembering what conditions make one or another fast, it's possible to choose one or another dynamically, so the performance will almost always be optimal. Say, the remembering bits start empty, and will run both versions in parallel. After some runs, it's possible to determine what conditions make one "always" fast, and under what conditions they run almost the same. After this statistic in place, then the code starts running only one version per request, and always will be a version that: Is faster; or. Has the same performance as the other. Let some small percent of requests run in parallel, even after the statistic is formed, to allow a dynamic calibration of said statistic.
algorithm-analysis .net-core
View Question ↗
Question
Parent Entity
Score: 9 • Views: 3,561
Site: softwareengineering