Question 6
Recursive drawing can create complex patterns from a few instructions, sometimes called algorithmic art. These are examples of a Koch curve and recursive circles.


Recursion means that a function calls itself, like repeated reflections between facing mirrors. The source gives this DrawSquare(x,y,s) algorithm:
1. Draw a square of side s centered at (x,y).
2. If the side length is smaller than 2 pixels:
DrawSquare(x+s/2,y,s/2), a smaller square to the right;
DrawSquare(x−s/2,y,s/2), a smaller square to the left.
Which pattern can be produced?

Editorial convention for the conditional answer: preserve the printed “smaller than” rule above, but for a terminating drawing interpret recursion as continuing while s≥2 and stopping after drawing when s<2. The intended correction is not confirmed by the source.


Recursion means that a function calls itself, like repeated reflections between facing mirrors. The source gives this DrawSquare(x,y,s) algorithm:
1. Draw a square of side s centered at (x,y).
2. If the side length is smaller than 2 pixels:
DrawSquare(x+s/2,y,s/2), a smaller square to the right;
DrawSquare(x−s/2,y,s/2), a smaller square to the left.
Which pattern can be produced?

Editorial convention for the conditional answer: preserve the printed “smaller than” rule above, but for a terminating drawing interpret recursion as continuing while s≥2 and stopping after drawing when s<2. The intended correction is not confirmed by the source.