Tag Archives: algorithm
Spiral Walk
Published on February 3rd, 2008.
We have a square matrix (NxN) of integers. Having given a starting corner point and a direction, we want to walk all the elements from this matrix on a spiral way. I found this problem accidentally and it vexed me. That’s why I decided to create a simple algorithm.
We are going to create a class called SpiralWalk. It provides a method called WalkIt which does all the job. This methods has three arguments: starting row & col index (zero-based) and a direction. Remember, that the point must be a corner point. Every NxN array has four corner points: (0, 0), (0, N-1), (N-1, 0), (N-1, N-1). (more…)
Filled under C#. No Comments.
Prim’s Algorithm
Published on February 2nd, 2008.
In the Graph Theory, Prim’s algorithm creates an optimal spanning tree. I will show here my implementation of this algorithm. It is used in the Graph Lib that I showed you earlier. I don’t pretend that it is done the best way, but it’s working completely. (more…)
Filled under C#. No Comments.