Current Mood: focused
Current Music: "I Am the Very Model of a Modern Major-General", from The Pirates of Penzance by Gilbert & Sullivan
Sure, the Ship of Fools are a hearty, laughing, jovial crew, to be sure. We are all close friends, with diverse talents, skills, comedy styles, and ideas. Every time we're on stage, it's a delicate balance between ego, performance, humor, thought, confidence, and trust.
Given that, you must wonder what we do when we're NOT doing improv.
That, my friend, looks a little something like this:
void sortArray(int *array)
{
int n = 0;
int lcv;
int lowVal;
int pos;
int Temp;
while(n < ARRAYSIZE - 1 )
{
lcv = n;
lowVal = array[lcv];
pos = lcv;
while(lcv <= ARRAYSIZE - 1 )
{
if (array[lcv] < lowVal)
{
lowVal = array[lcv];
pos = lcv;
}
lcv ++;
}
Temp = array[n];
array[n] = lowVal;
array[pos] = Temp;
n ++;
}
printf("The array has been sorted!\n");
}
That's right. Scott and I spent three hours last night working on some hardcore array selection sorting code, and this is the end result. This accepts an array of 50 randomly generated integers (from another part of the program that was developed last week in lab, using pointers/address references) and searches the entire array from the first for the smallest value. Then, it swaps the smallest value with the first, and starts on the second. This continues until the entire 50 value array is sorted sequentially.
We also discussed a really kickass concept called radix sorting, which, on a computational level, is so much more efficient (as opposed to binary searching, which we learned on Monday). You have to meet a few conditions to make sure it works (integers, n >> known bounds), but it made sense. You keep re-sorting all the values by increasing position (ones, tens, hundreds, etc.) into integer "bins", and when it's finished, you have sorted data. I hope I get asked about sorting in an interview. I will rock their feeble world.
Now I just have to worry about my CS project, my COM group presentation, my math exam, my CGT CATIA exam, my CS lab practical, work, the rest of my homework, and if I'm even going home for Thanksgiving break...
Subscribe to:
Post Comments (Atom)
Impressive man from NASA: Now, Mr. Garwood, we must know, do you know anything about sorting?
ReplyDelete*Ryan nearly pees self in excitement*
you crazy bastard...
ReplyDelete