String Reversal

In this example we can watch as a string of characters is reversed using
recursion. This could be achieved without using recursion by reading the
characters of the string into a Vector and and then printing out the
vector in reverse order.

We could however use a far simpler algortihm if we were to employ recursion...

  1. In area A the Java source code for the recursive algorithm
    used to reverse the string is displayed.  As the algorithm executes
    the current line of execution is highlighted. 
  2. This animation shows pictorially how this algorithm reverses
    a given string using recursion. 
  3. This is the the levels of recursion.  This bar graph
    shows the current level of recursion, (i.e. the number of recursive calls
    on the stack) 
  4. Gives a textual explanation of  the line currently under
    execution in A.  Use the speed control bar (E) to slow down the algorithm
    so that you can read each message and follow the "code walk through" at
    your own pace.
  5. Can be used to enter a String of characters to be reversed.
  6. This speed control allows you to speed up and slow down the
    rate at which the algorithm executes.