Oh My God Complexity

OhMyGodComplexity, in pseudo BigOh notation O(My God), is a play on Bachman-Landau BigOh notation to describe the run-time complexity of a naive algorithm. Common cases are "brute-force" algorithms implemented in lieu of a much more elegant possible solution, or typos or other minor coding errors which do not affect the accuracy of results (which is usually the primary focus of testing), but which do increase the complexity of the algorithm (often by resetting loop counters or bounded constraints).

For instance, QuickSort is normally implemented as "choose a pivot value from the collection, rearrange the collection to place all elements less than the pivot to the left and all elements greater then the pivot to the right, then QuickSort each side of the rearranged collection." If the code to sort the "left half" of the collection was always given index 0 as the lower bound to work in, then when sorting each "right half" (where the starting index is N/2), the code to sort that half's "left half" would start back at zero. This will not affect the results, but will dramatically increase the number of element traversals and comparisons making the algorithm approach N^2 complexity.


EditText of this page (last edited August 29, 2012) or FindPage with title or text search