updated
authorChristian Urban <urbanc@in.tum.de>
Mon, 24 Sep 2018 11:05:39 +0100
changeset 558 447ed6c7cdad
parent 557 9ab8a6fc58c0
child 559 db5cb071644d
updated
progs/catastrophic.java
progs/catastrophic.py
progs/catastrophic.rb
--- a/progs/catastrophic.java	Sun Sep 23 09:04:24 2018 +0100
+++ b/progs/catastrophic.java	Mon Sep 24 11:05:39 2018 +0100
@@ -1,7 +1,16 @@
-// a case of catastrophic backtracking in Java
+// A case of catastrophic backtracking in Java 8
+//-----------------------------------------------
 //
 // regexp: (a*)*b
 // strings: aa....
+//
+// compile:    javac catastrophic.java
+// call with:  java catastrophic
+//
+// IMPORTANT: 
+// Java 9 improved its regex matching engine.
+// This example is now much faster.
+//
 
 import java.util.regex.*;
 
--- a/progs/catastrophic.py	Sun Sep 23 09:04:24 2018 +0100
+++ b/progs/catastrophic.py	Mon Sep 24 11:05:39 2018 +0100
@@ -2,15 +2,26 @@
 import re
 import sys
 
-# case of catastrophic backtracking in Python
+# A case of catastrophic backtracking in Python
 #
 # regex: (a?){n} a{n}
 # strings: aa...
 #
+# call with:
+#
+#   > ./catastrophic.py 20
+#
+# or
+#
+#   > ./catastrophic.py 28
+#
+#
 # call with timing as:
 #
 #   > time ./catastrophic.py 20
 
+
+
 # counter n given on the command line
 cn = sys.argv[1]
 
--- a/progs/catastrophic.rb	Sun Sep 23 09:04:24 2018 +0100
+++ b/progs/catastrophic.rb	Mon Sep 24 11:05:39 2018 +0100
@@ -1,4 +1,15 @@
+# A case of catastrophic backtracking in Ruby
+#---------------------------------------------
+#
+# regex: (a?){n} a{n}
+# strings: aa...
+#
 # example provided by Daniel Baldwin
+#
+# call with:
+#
+#   > ruby catastrophic.rb
+#
 
 nums = (1..1000)