c m y k
85www.
openITis.
com | LINUX For YoU | AprIL 2008
W
hen we hear of some strange algorithms
with names like ‘Dijkstra’s shortest path’,
‘Markov’s string replacement’ or ‘Sieve of
Eratosthenes’, we usually dislike the arcane and dry
solutions they...
More
c m y k
85www.
openITis.
com | LINUX For YoU | AprIL 2008
W
hen we hear of some strange algorithms
with names like ‘Dijkstra’s shortest path’,
‘Markov’s string replacement’ or ‘Sieve of
Eratosthenes’, we usually dislike the arcane and dry
solutions they describe.
However, such algorithms
can have interesting applications or can provide
some unusual solutions that are not possible with the
straightforward solutions we often arrive at based on
common sense.
We’ll explore ‘Markov’s string replacement’
algorithm in this article.
What this algorithm does is
simple string rewriting based on a set of rules.
Let’s
look at an interesting application of this algorithm:
converting a binary to unary by string replacement,
by applying a set of rules.
The idea described here is
from en.
wikipedia.
org/wiki/Markov_algorithm
Let us look at the rules first:
• Rule 1: “#0” => “0##”
• Rule 2: “1” => “0#”
• Rule 3: “0” => “”
• Rule 4: “#” => “1”
The symbol ‘=>’ stands for ‘replace with’.
Take any
bi
Less