Tag Archives: mathematics

Use branch and bound to 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. The example … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | Leave a comment

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 | Tagged , , , , , , , , , | 1 Comment

Draw a Fibonacci word fractal in C#

This example uses the Fibonacci word to draw a fractal curve. For information on the Fibonacci word, see the post Calculate Fibonacci words in C#. To draw a curve with level N, use Fibonacci word number N. Loop through the … Continue reading

Posted in algorithms, fractals, graphics, mathematics | Tagged , , , , , , , , , , , , , , , | Leave a comment

Calculate Fibonacci words in C#

You can find Fibonacci words by concatenating previous Fibonacci words much as you calculate the Fibonacci sequence by adding previous values in the sequence. The first two Fibonacci words are: S0 = 0 S1 = 01 The following Fibonacci words … Continue reading

Posted in algorithms, fractals, graphics, mathematics | Tagged , , , , , , , , , , , | 1 Comment

Use the BigInteger structure in C#

The long data type can hold values between roughly -9.2 x 1018 and -9.2 x 1018, but sometimes even that range isn’t big enough. The .NET Framework 4.0 (C# 4.0 or Visual Studio 2010) introduced the BigInteger structure to represent … Continue reading

Posted in mathematics | Tagged , , , , , , , , | Leave a comment

Generate letters with given frequencies in C#

This example generates random letters with the frequencies they have in normal English text. The following code shows how the example gets started. // The letter frequencies. See: // http://en.wikipedia.org/wiki/Letter_frequency private float[] Frequencies = { 8.167f, 1.492f, 2.782f, 4.253f, 12.702f, … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | Leave a comment

Draw a picture-filled histogram in C#

The example Make a simple histogram in C# shows how to draw a histogram. This example shows how to fill the histogram’s bars with pictures. The following TileRectangle method fills a rectangle with an image. // Tile an area from … Continue reading

Posted in drawing, graphics, mathematics | Tagged , , , , , , , , , , , , | Leave a comment

Linkback to the Secret Santa Problem

Tom left a comment to my post Calculate the number of secret Santa permutations in C#. He used that example to build a site in JavaScript explaining how the algorithm works. It’s a pretty cool little page. Drop by and … Continue reading

Posted in algorithms, combinatorics, mathematics | Tagged , , , , , , , , , , , , , | Leave a comment

Make a dice-rolling simulation in C#

This example performs a simulation of rolling two six-sided dice. It’s related to my book Interview Puzzles Dissected, which includes several examples that involve rolling dice. When you enter a number of trials and click Roll, the program uses the … Continue reading

Posted in algorithms, graphics, mathematics | Tagged , , , , , , , , , , , , | Leave a comment

Draw the Weierstrass function in C#

The Weierstrass function was discovered by Karl Weierstrass in 1872. It’s an odd function that is continuous everywhere but differentiable nowhere. I’ll explain what that means shortly. Here’s the function: Here: The following two sections explain what it means to … Continue reading

Posted in algorithms, drawing, fractals, graphics, mathematics | Tagged , , , , , , , , , , , , , , , | Leave a comment