View Full Version : Algorithm of the week/month?

16th November 2006, 11:11 AM
I was thinking about what would make this forum more active... and I thought of perhaps doing an algorithm of the month or week; I know there are a number of professional programmers and computer science students here that could write worthwhile well documented algorithms every once in a while. And I think it would answer a lot of questions for people that are in CPS classes.

20th November 2006, 09:16 AM
sounds like an interesting idea... are we talking new algorithms here or old ones that we discuss?

20th November 2006, 05:34 PM
If you make it algorithm of the week, you could get a blend of the two. Have a few weeks focused on discussing known algorithms, and have a few for members to post ones they've written, and have people review them, suggest improvements, and the like?

I'd think it's too much to ask that people generate new algorithms that often, so review of older ones is probably needed.

24th November 2006, 02:57 PM
There aren't a lot of great new algorithms coming out that many people here would understand. I mean some of the classics, dijkstra, bin sort etc.

25th November 2006, 04:37 PM
Well, you could have ones that aren't necessarily new, but just not famous. Like, for my project now I'm going to be writing an algorithm that takes a 2d array of any size and rotates it 90 degrees. That's not really a classic, but it's something that can be put up and discussed.

25th November 2006, 07:04 PM
well I mean more difficult algorithms...and the classics are kinda important... That one isn't all that hard to do, and is pretty much guaranteed O(N) efficiency. I mean the ones that have a right and wrong ways to do..
here's the solution to that algorithm btw ;P

void invert(char &array, int x_dim, int y_dim) {
int j = 0;
char temparray[y_dim][x_dim];
for (int i = 0; i < x_dim; i++) {
for (j = 0; j < y_dim; j++) {
temparray[j][i] = array[i][j];
array = temparray;

25th November 2006, 07:28 PM
Actually, that didn't work. It rotated it 270 degrees, then flipped it vertically. Close though. And much simpler than... my original way. Which will now be burned.

Anyways, if you're looking to increase activity, it might be better to include easier algorithms for people who are trying to learn, rather than who already know?

26th November 2006, 08:46 AM
my bad in the assignment make it [i][j] ;p I didn't test the algorithm

1st December 2006, 06:41 PM
static boolean[][] rotate(boolean[][] a) {

int size = a[0].length;

boolean[][] temparray = new boolean[size][size];

// Stores rotated values in temparray
for (int i = 0; i < size; i++) {

for (int j = 0; j < size; j++) {
temparray[i][j] = a[j][size - 1 - i];
} // end inner for

} // end outer for

return temparray;
} // end rotate method

Turns out that was the trick.

Anyways... on topic... Someone set this up? I suppose you could just make the thread, and wait for someone else to sticky it.

3rd December 2006, 11:55 AM
that sounds like it'd probably be the best plan would be to just write one and wait for a sticky.