As you can see after clicking the green flag, the recursively drawn tree makes 2^n calls for a depth of n. This appears to be very inefficient since many of the nodes are redundant. Is there any way to write the code to reduce the call count? Note you can change n via slider and redraw with "space"
See inside for scripting ** Now with "memoization". An alternative recursion script was created that saves the (x,y) position of each node. Before drawing a series of branches, the script will first check if that (x,y) was previously visited and drawn. If it is already in the list, it just moves along. Both scripts consecutively run... note the difference in call counts!