Category Archives: recursion

Recursively draw equations in C#

The basic idea for recursively drawing equations is simple. Well, sort of simple. Classes represent different kinds of equations. A particular class knows how to draw its kind of equation. It uses other classes to draw its pieces. For example, … Continue reading

Posted in algorithms, drawing, fonts, graphics, recursion | Tagged , , , , , , , , , , , | 2 Comments

Enumerate TreeView nodes in C#

The previous two posts show two ways you can enumerate TreeView nodes that are checked. The idea is to recursively crawl over the tree’s nodes and pick out the checked ones. Unfortunately that method isn’t easily extendable. For example, if … Continue reading

Posted in algorithms, controls, recursion, user interface | Tagged , , , , , , , , , , , , , , , , | Leave a comment

Yield checked TreeView nodes in C#

The previous example used recursion to traverse the nodes in a TreeView control and fill a list with the nodes that are checked. This example uses a slightly different approach. It traverses the TreeView control’s nodes and uses the yield … Continue reading

Posted in algorithms, controls, recursion, user interface | Tagged , , , , , , , , , , , , , , | Leave a comment

Make a list of checked TreeView nodes in C#

If you set a TreeView control’s CheckBoxes property to true, then the control displays boxes that the user can check to select nodes. In that case you will probably need to find the checked TreeView nodes at some point. Strangely … Continue reading

Posted in algorithms, controls, recursion, user interface | Tagged , , , , , , , , , , , , , | Leave a comment

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