- Naïve algorithm
A
naïve algorithm is typically a very simple solution to a problem, which represents the intuitive approach taken by one unfamiliar with the problem domain. It is meant to describe a suboptimal algorithm compared to a "clever" (but less simple) algorithm. Naïve algorithms usually consume larger amounts of resources (time, space, memory accesses, ...), but are simple to devise and implement.An example of a naïve algorithm is
bubble sort , which is only a few lines long and easy to understand, but has a O("n2") time complexity. A more "clever" algorithm isquicksort , which, although being considerably more complicated than bubble sort, has a O("n log n") average complexity. For instance, sorting a list of 100 items with bubble sort requires 10,000 iterations, while sorting the same list with quicksort requires approximately 1000 iterations, making quicksort a much faster algorithm than bubble sort.As demonstrated above, naïve algorithms are mostly used for
prototyping purposes, as they are often not acceptable in production-level software products.Another sense of the term implies an algorithm which may have certain bugs, or fail to account for corner cases; for instance, the
naïve implementations of various operations onlinked lists andbinary trees either leak memory or corrupt data based on incorrectpointer arithmetic.
Wikimedia Foundation. 2010.