What is a polymorphic algorithm?
Location: http://www.jguru.com/faq/view.jsp?EID=213780 Created: Sep 22, 2000 Modified: 2005-08-17 01:43:25.62 Author: Avi Kak (http://www.jguru.com/guru/viewbio.jsp?EID=26410) In general, an algorithm is called polymorphic if it can achieve the same functionality using different data structures. For example, if the same sorting or searching algorithm could be used with different types of containers, such as vectors, lists, maps, etc., then that algorithm would be called polymorphic. As a case in point, the generic algorithms of the STL library in C++ are polymorphic because they can be used for different container classes. In the context of Java collections, the polymorphic algorithms are all supplied by the various static methods of the java.util.Collections class. Consider, for example, the method sort(List list). This method is capable of sorting any collection that has implemented the List interface, and that includes containers of types ArrayList, LinkedList, Vector, etc.