Encyclopedia > Wikipedia:Algorithms on Wikipedia

  Article Content

Wikipedia:Algorithms on Wikipedia

Wikipedia, unlike most traditional Encyclopedias, contains detailed descriptions of many algorithms, often with sample implementations.

This is a draft of hints for good sample implementations of algorithms for Wikipedia. Further discussion is invited.

The main purpose of sample implementations is to help the reader understand the algorithm, not to provide ready-to-use code. Implementations should be easy to read and understand for average programmers or computer science students.

Programming languages which many people use or understand should be used. Suggested languages are C (especially where lower-level features are needed) Java or C++ (especially when demonstrating object-oriented algorithms or patterns), Perl, and Python. Languages with a small user base like Smalltalk or Eiffel are discouraged.

There is some controversy about sample implementations in Ruby and pseudocode. Ruby has an advantage of being very readable and a disadvantage of not being very popular. Some people prefer pseudocode, because an algorithm in pseudocode isn't obfuscated by implementation details. This is a major advantage as compared to some other languages (like C), but is a very small advantage as compared to other languages (like Python and Ruby). Other arguments against pseudocode are that it's not standardized and is hard to test.

Dialects of Pascal and BASIC can have considerable incompatibilities, so if those languages are used, care should be taken to use only their most universal features. It's good to avoid language-specific constructs in examples. For example, Perl code should avoid the use of that language's more unique and unusual features that programmers of other languages may find confusing.

Using iteration is usually preferred over using tail recursion because this is a more popular way of coding and because popular implementations of some languages do not support constant-space tail recursion.

In the case when these hints aren't sufficient to make decisions, it's okay to provide more than one sample implementation.

A list of algorithms is available.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Flapper

... fashion and popularized short hair for women. Actresses mimicked the style, and even cartoon characters such as Betty Boop and Minnie Mouse got into the act. Despite ...

 
 
 
This page was created in 40.2 ms