Popular recipes by bartender http://code.activestate.com/recipes/users/4185259/2013-02-14T22:00:22-08:00ActiveState Code RecipesGenerating Balanced Parenthesis (Python) 2013-02-14T22:00:22-08:00bartenderhttp://code.activestate.com/recipes/users/4185259/http://code.activestate.com/recipes/578458-generating-balanced-parenthesis/ <p style="color: grey"> Python recipe 578458 by <a href="/recipes/users/4185259/">bartender</a> (<a href="/recipes/tags/algorithm/">algorithm</a>). </p> <p>The python code generates balanced parenthesis recursively. Example for depth=3 i.e. 3 opening brackets and 3 closing brackets,the sample output should be:</p> <p>((())) (()()) (())() ()(()) ()()()</p> <p>The number of such output ( 5 in above case) is a Catalan Number.</p>