Because I have nothing new to add to what I’ve already said; they’re all still valid.
More practice: sorting
Sunday, February 22, 2009
I wanted to try my hand at sorting, this time, because it’s something I never got around to doing in the past. So I quickly whipped up around ten thousand random integers, put it in a text file, and went to work. My first idea was to do a bubble sort, but the idea of performing comparisons two at a time Instead, I went with the following algo (I forgot what it’s called):
- Find the smallest number in the list
- Swap it with the first element
- Find the next smallest number
- Swap with the second element
- Repeat until the last element is reached
I placed ten thousand random integers onto a file, “intlist”, read from it, and placed the values in a vector; I decided to use a vector because I didn’t want to have to bother re-learning linked lists, and I wanted to try various amounts of random numbers later on. Note that, at this point, performance is not yet an issue; I just wanted to do a sort. Code after the jump.
A BIR Story
Contrary to popular belief, there are actually THREE things in life that are certain: Death, Taxes, and frustration with your tax collector.
Quick and Dirty Test for Primes
Saturday, February 21, 2009
Again, just practicing; this time, on how to determine whether a given number is prime or not. This was actually the first C problem I ever encountered waaay back in the day; I remember failing. Miserably. Anyway, a refresher: in mathematics, a prime number (or a prime) is a natural number which has exactly two distinct natural number divisors: 1 and itself. Which means, naturally, that even numbers (except 2) are out, so I started there. Then I’d test the given number by dividing it by every odd number from 3 to the square of that number (because we don’t need the LARGEST factor; just A factor). After I did this exercise, I looked up other, more sophisticated methods (notably here); mental note to self: learn this.
We all want to change the world
Friday, February 20, 2009
I recently sat across some people who were talking about a project one of them was involved in; from what I could discern, it was some book-sharing thing that’d conceivably give poor schools access to a pool of books and other resource materials. Or at least, I think that’s what they were talking about. If that’s what it was, then it’s really one of the things I can get behind; in my brief experience teaching at a couple of local colleges, I’ve found that most of my students cite Wikipedia as their primary source for information for their papers. Now, Wikipedia is a great, convenient source of information, but it’s very nature makes it unreliable for any sort of serious academic research; there’ve been too many instances of incorrect or misleading entries for it to be a credible authority. Unfortunately, for an overwhelming majority, it’s the best source of information they have.
How great companies turn crisis into opportunity
People who take credit in good times and blame external forces in bad times do not deserve to lead. End of story. Jim Collins on Fortune.com
Nothing says “I love you” like “all you can eat”
Valentine’s Day is largely a construct of greeting card companies and flower shops around the world to boost sales; sometimes, though, it gets to means something truly special: slabs upon slabs of Angus beef.
No Fun with Roman Numerals
Friday, February 13, 2009
I was going over the ICT Proficiency sample exam earlier because apparently I’ve got to take it pretty soon — nevermind that I’m a design guy, and not, you know. A geek. Yeah, go figure. But wish me luck, too, because this is what I’ll have to deal with:
Hobson's Choice
Needless to say, this had me silently cursing: PHP I can do just fine; and I’m still in awe of the possibilities with Python (I always end up thinking: whoa… you can do that in Python?! Is this a noob thing? Because so many things are just darn easy in Python!). But I haven’t even looked sideways at any C code since 1997, never got over my fear of Java, and the last version of Visual Basic I used was VB4. Oh, and I don’t even know what COBOL code looks like. So yeah, SOL. I’ve decided to go the C/C++ route because it’s the most familiar, and for the life of me, I cannot do the simplest things in Java without needing to look something up. Same goes, strangely enough, for VB.
Read More

Subscribe via Email