Trial and error is a method for obtaining knowledge, both propositional knowledge and know-how. In trial and error, one tries an option to see if it works. If it works, then we have a solution. If it doesn't work - there is an error - then one tries another option.
In some versions of trial and error, the option that is a priori viewed as the most likely one should be tried first, followed by the next most likely, and so on until a solution is found, or all the options are exhausted. In other versions, options are simply tried at random.
Bogosort can be viewed as a trial and error approach to sorting a list.
Trial and error has a number of features:
- solution-oriented: trial and error makes no attempt to discover why a solution works, merely that it is a solution.
- problem-specific: trial and error makes no attempt to generalise a solution to other problems.
- non-optimal: trial and error is an attempt to find a solution, not all solutions, and not the best solution.
- needs little knowledge: trial and error can proceed where there is little or no knowledge of the subject.
The scientific method can be regarded as containing an element of trial and error in its formulation and testing of hypotheses. Also compare genetic algorithms, simulated annealing and reinforcement learning - all varieties of search which apply the basic idea of trial and error.