0

I have a program to write in which I need to create the following fractal pattern using recursion:

[img]http://img19.imageshack.us/img19/7456/73284540.png[/img]
^image link

My professor said two recursive calls are needed, and 2 parameters are also needed. One parameter indicates the indentation of the leftmost line, while the other indicates the number of stars in the largest line.

I really need help with this. I have no idea where and how to start this. And it is due this Monday.

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by BestJewSinceJC
0

You need two methods because there are two independent patterns in that picture. The first pattern is the one that looks like:

*
**
*

And the second pattern is the one that switches between printing 4 stars and 8 stars. All you need for the first method is something that prints the first pattern I showed you above. All you need for the second method (the one that switches between printing 4 stars and eight stars) is a counter. If the counter is a multiple of 2, you print eight stars. Otherwise, you print 4 stars.

Oh, and the recursion comes into play because after the first method prints its stars, it needs to call the second method to print its stars. The second method can then call the first method again. You need to also remember that you'll need some way to decide when to stop printing stars.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.