Category Archives: recursion

Loop over an array of unknown dimension in C#

The previous post Loop over entries in an array of unknown length in C# explains how to loop over the entries in a one- or two-dimensional array, but what do you do if you don’t know how many dimensions an … Continue reading

Posted in algorithms, arrays, recursion, variables | Tagged , , , , , , , , , , , , , , , , | 1 Comment

Animate the Tower of Hanoi problem in C#

This example is similar to the example Recursively solve the Tower of Hanoi problem in C# except it uses animation to show how the disks move from one peg to another. The following AnimateMovement method moves a disk in a … Continue reading

Posted in algorithms, animation, drawing, graphics, multimedia, recursion | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Recursively solve the Tower of Hanoi problem in C#

The example Recursively draw a binary tree in C# uses recursion to draw the branches of a tree. Good examples of recursion are hard to come by because the human brain normally thinks iteratively. For example, if you need to … Continue reading

Posted in algorithms, drawing, recursion | Tagged , , , , , , , , , , , , , , | Leave a comment

Generate all of the permutations of a set of objects in C#

The basic idea is to use a recursive method to assign the next item in a permutation. The first call to the method assigns the permutation’s first item, the next call assigns the second item, and so forth. To assign … Continue reading

Posted in algorithms, combinatorics, mathematics, recursion | Tagged , , , , , , , , , , | 10 Comments