CIS 068 / 2: Lab-Assignment #7: Reversing a String using a Recursive Function OR Creating a Fractal Tree

You can choose between two assignments this time, the first is quiet simple, while the second one is more challenging.
I leave it to you which one you want to finish, i recommend the first one if you didn't finish at least one of the previous assignments so far.
Scores for the assignments:
first: 5 points
second: 7 points

Work only on ONE of these assignments, if you solve both only the second one will be scored, hence it is NOT possible to achieve the sum of scores (5 + 7) !


Assignment 1:
No graphics this time !

Write a program that reverses a string, e.g. string "Hello" => "olleH".
The string can be passed to the program by command line or interactively, whatever you like better.

The important part is: the program MUST be designed RECURSIVELY, hence no programs written ITERATIVELY (i.e. using a loop-construct) will be scored (although they might show the same result).

Hint:
You might need the following String-methods, defined in the class java.lang.String:

Please refer to the JAVA API for their usage.

Score: 5 Points


Create a Fractal Tree

Create a fractal tree as seen on my slides. The program MUST be designed recursively.
A fractal tree consists of 2 branches, forming a 'V'. On the tip of each branch there is a new 'V', having a branch-length which is smaller (a fraction, e.g. 1.8) than the length of the parental 'V'.

Only program the basic fractal tree, don't copy the interactive part (sliders etc.) of the example program on my slides.

Hints:
Each V consists of 2 branches...
Your function will need the parameters:

The stopping case will depend on the branch-length. Look at the applet on my slides and play with the parameters, this will give you a lot of ideas.

Score: 7 points


Good Luck !