So far in the course we are finally merging in the knowledge of CSC165 and CSC148 to create real-life applications of our knowledge of computer science. A famous question in computer science which is likely well known by almost every computer scientists is P = NP, and learning measurement of algorithm run time is the first step in relation to learning the heart of computing.
Measurement of time algorithm is very useful and quite interesting. Often when looking for coding help, I'll see people on StackOverflow arguing over optimization of code, and this is especially important for me!I paid quite close attention to this unit as it was genuinely interesting (a bit more interesting than the previous units which was also quite interesting as I've posted before).
As a web developer, optimization is extremely important, especially when your database usually contains a huge amount of data that needs to be fetched, sorted, indexed, inserted, modified, updated, fetched randomly, etc. There is one scenario that requires me to quickly sort a list of items by their ranking, prior to which I would often use something that I now know to be called bubble sort, which of course runs in polynomial time, significantly slower than quicksort and mergesort (that I now use). Another example is I would have one large table (about 1 million rows) that were partitioned into multiple tables and needed to do a weighted random selection on them with each row occupying a "range" of a total sum. At first, my weighted selection was very slow, about 10 seconds, as I needed to calculate the sums, generate some random value and then race through all the partitioned tables to find the weighted post.
However, after learning exactly how BTREE indexing works and through that researching on Fenwick trees (which are actually optimized to run in log(n) time for this sort of criteria which includes optimization of calculating prefixed sums), I was able to apply big Oh calculations as well as measuring the runtime of multiple ways to select the random post (ended up creating a prefixed table of sums), I managed to get down selection all the way from nsqrt(n) time and eventually very close to sqrt(n) time (not quite log(n) time because there were admittedly some data structures I didn't quite understand in the fenwick tree).
This class knowledge about measuring runtime HAS helped significantly in my coding process as well as with multiple other selection and sorting methods I use on multiple other databases, and I look forward to furthering my knowledge by reinforcing my knowledge from reviewing the lectures and doing some practice questions.