CST370 week 2
This week started with a review of the time category of algorithms and the three asymptotic notations we use to specify the bounds of an algorithm's time category. Big Omega is used to denote the best case boundary. Big O is used to denote the worst case boundary. Big Theta is used to denote a tight bound, where best and worst is the same time category.
The time categories, in ascending order are 1, log n, n, n*log n, n², n³, 2ⁿ, and n!. Given the same amount of data being processed, the further left the faster the algorithm, and the further right the slower the algorithm.
We learned about how to identify the category, by dropping all lower order terms and any constant coefficients to get the final category. For example, 5n*log n + 2n +14 is O(n log n). This is more straightforward to analyze in non-recursive algorithms because we count basic operation in loops or nested loops. Recursion doesn't loop per se, so we solve with backwards substitution by counting the basic operations per nested call and substitute from F(n) down to the base case of the recursion.
We were also introduced to brute force algorithms. They're not always the most time optimal solution, but are usually the simplest to implement, so it's often worthwhile to start solving a problem with brute force and optimize later.
Comments
Post a Comment