Inferring algorithm from behaviour

A behaviour results from the sequence of steps that an algorithm performs: the transformation that it applies to the input to generate the output, as well as the environmental footprint (resources used).

For example, a bubble sort returns a sorted array given an unsorted one. It consumes O(n²) resources. Furthermore, it is known that the pattern of operation on the data can be represented visually like the following (Found on Wikipedia - colour would have been preferable):
Bubble sort animated

Therefore, a computer program watching the behaviour of a process whose only function is to bubble sort a file would be able to infer the function of the process. Further, it would be possible to infer the same while watching a larger process whose one of the subroutines is the bubble-sort.

What's needed is to repertory the behavioural patterns of known algorithms and match them against the output of a process monitoring program.