04.17.06

Computer Science II – Assignments 4 & 5

Posted in ALPHA, College, Computer Science, Programming, School at 10:13 pm by Nick

Time: 4 hours
Total: 70 hours
————————–

Wow, an update on all of this finally! Since I’m lucky I can count my time programming on homework towards my project.

Due to recent events, I missed quite a bit of class at UNI. I’m pretty sure I’m still ahead of the game though. The two updates are the two most recent homework assignments.

Assignment #4 called for expanding a Vector class O’kane had established previously. This was just a chance to use operation overloads. For the unknowning, C++ allows you to override various operators (+,-,/,*,++,- -). Thus, you can build your class into the language and not only write more concise code, but cleaner code. Its all quite nifty.

Assignment #5 was strange. I guess in class they were talking about sorting arrays (again) and O’kane decided to have them use the qsort() and bsearch() functions. The two standard functions are for array manipulation within C (and C++ for that matter). You specify your own comparison functiion and a few other details and it will do all of the hard work for you. It is also quite fast. We tested it on a 1.3 meg file full of medical terminology (used in a previous assignment as well). It took about a second to read and sort all 39,824 entries on my piece of crap computer. Looking up was also quick.

One of the strange thigns about the assignment was that we had to seek back to the stored file position and read it in again, so it was all directly from the file. This is good practice for new programmers who don’t know how to traverse text files very well. However, I became very good at it with the X-Log Library, as my crash guard used file seeking a bit.

You can find the source and typescripts in the links below. The typescripts hold the source code, a compilation statement, and a test run. However, the code looks a tad funky, so I suggest looking at the source files for the code itself:

Assignment #4 – http://www.nick-cash.com/download/cs2/4
Assignment #5 – http://www.nick-cash.com/download/cs2/5

Leave a Comment