Category: Computer Science

Solving the Towers of Hanoi puzzle in C#

4 August, 2009 (18:45) | .Net, Programming, C#, Computer Science

I thought this would be a fun little exercise to try. This puzzle is generally used to teach recursion in CS classes, but I have never actually tried to implement it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TowersOfHanoiCs
{
class Program
{
static List […]

Programming vs. Engineering vs. Mathematics.

20 June, 2008 (17:28) | Programming, Humor, Computer Science

An experiment was conducted in order to study the differences between programmers, engineers, and mathematicians. One programmer, one engineer, and one mathematician were all locked in separate classrooms for one week. Each classroom contained all of the normal things you’d find in a classroom: chalkboard, chalk, desks, etc. In addition to that […]

Implementation of DES in C

16 March, 2008 (23:31) | Cryptography, Security, Code, Computer Science


The difference between Java’s “final” and C#’s “const”

15 February, 2008 (20:01) | .Net, Java, C#, Computer Science

Final in Java is used to declare a class that can’t be subclassed, a method that can’t be overridden, or …
A final variable means the value won’t change, but the value can still be determined at run time:

final int i;
if ( j > 0 ){
i =1;
} else {
i = […]

Learning to program: A complete curiculum

17 November, 2007 (16:28) | Programming, Computer Science

I’ve seen many, many posts in forums asking about some good books to read to either get started in computer science, or what next steps to take after having read one intro book on a specific language. Of course none of them state what their goals are, other than they “want to learn to […]

Passing immutable types by reference in Java and C#

12 October, 2007 (18:26) | Java, C#, Computer Science

To many, it should be obvious what the following code prints:

public static void main(String[] args){
int x=0;
SomeMethod(x);
System.out.println(x);
}

protected static void SomeMethod(int x){
x=1;
}

The code prints 0, because “int” is a native type and is passed by value. […]

Does string interning in C# guarentee you only get one copy of a static value?

19 September, 2007 (22:15) | .Net, C#, Computer Science

Of course the answer is no, otherwise it wouldn’t be a very interesting post. The concept of interning is an attempt to save memory by allocating static values which match exactly to the same memory location, without regard to where they’re used in the application. But here’s in instance where it doesn’t quite […]