Example: A 1 A 6 3 3 3 5 5 - 3 3 3 4 - 3 3 3 - 1 2 - 1 - - 1 1 2 3 6 2 3 6 i j 4 5 4 5 PRINT-OPT-PARENS( s, i, j ) if i = j then print “A” i else print “(” PRINT-OPT-PARENS( s, i, s[i, j] ) PRINT-OPT-PARENS( s, s[i, j] + 1, j ) print “)” P-O-P(s, 1, 6) s[1, 6] = 3 i = 1, j = 6 “(“ P-O-P (s, 1, 3) s[1, 3] = 1 i = 1, j = 3 “(“ P-O-P(s, 1, 1) “A 1 ” P-O-P(s, 2, 3) s[2, 3] = 2 i = 2, j = 3 “(“ P-O-P (s, 2, 2) “A 2 ” P-O-P (s, 3, 3) “A 3 ” “)” “)” ( ( ( A 4 A 5 ) A 6 ) ) A 1 ( A 2 A 3 ) ) … ( s[1..6, 1..6]