Tag Archives: recursion

Find the highest value path through a two-dimensional array of numbers in C#

This method is similar to path-finding methods described in my books Essential Algorithms: A Practical Approach to Computer Algorithms and Interview Puzzles Dissected, Solving and Understanding Interview Puzzles. Follow those links for more information including tables of contents. Look at … Continue reading

Posted in algorithms, mathematics | | 1 Comment

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 | | 2 Comments

Iterate over items in an array with unknown dimensions in C#

This example shows how you can iterate over the items in an array that has an unknown number of dimensions. When it starts, the program executes the following code. private void Form1_Load(object sender, EventArgs e) { string[, ,] values = … Continue reading

Posted in algorithms, arrays, syntax | | 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

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

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

Display tooltips for TreeView nodes in C#

At design time, I added a TreeView control to the form. I also added an associated ImageList control to hold images for the TreeView control’s nodes, and I set the TreeView control’s ImageList property to the ImageList control. Finally I … Continue reading

Posted in controls, user interface | | 1 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 | | 3 Comments

Draw a recursive overlapping snowflake fractal in C#

The example Draw a recursive snowflake fractal in C# explains how to use an iterator and a generator to draw a snowflake fractal. This example uses the same technique with the initiator and generator shown in the second and … Continue reading

Draw a recursive von Koch snowflake fractal in C#

This example shows how to draw a von Koch snowflake fractal. It uses the same techniques described in the post Draw a recursive snowflake fractal in C#. The DrawSnowflake and DrawSnowflakeEdge methods are exactly the same as before. The … Continue reading