Week 4
Week 4 Learning Journal: Merge Sort, The Master Theorem, and Midterm Synthesis
Technical Summary:
Week 4 was a pivotal point in CST 370 as we transitioned from basic brute-force techniques to the Divide-and-Conquer paradigm. The primary focus was Merge Sort, a sophisticated sorting algorithm that employs a recursive strategy to achieve $O(n \log n)$ efficiency. The logic involves two distinct phases: the "Divide" phase, where the array is split into $n$ sub-lists (each containing one element), and the "Merge" phase, where those sub-lists are repeatedly merged to produce new sorted sub-lists until only one remains.
A major highlight of this week was applying the Master Theorem to analyze algorithm efficiency. The Master Theorem provides a mechanical way to solve recurrence relations of the form T(n) = aT(n/b) + f(n). For Merge Sort, the relation is T(n) = 2T(n/2) + \Theta(n). Since the work done at each level of the recursion (f(n)) matches the cost of the branching (n^{\log_b a}), the theorem places Merge Sort in "Case 2," resulting in a tight bound of \Theta(n \log n). This mathematical framework is much faster than the Backward Substitution method I used in previous weeks for simpler recurrences.
Reflection and Midterm Preparation:
The most challenging aspect was implementing the merge() function in Java. It requires precise pointer management to compare elements from the left and right subarrays and place them into the auxiliary array. I realized that while Merge Sort is highly efficient in terms of time, it is not "in-place," meaning it requires $O(n)$ extra space, which is a significant trade-off compared to simpler sorts.
Preparing for the Midterm on January 31st was an intensive process of synthesizing everything from Big-O notation to Graph Traversals (BFS/DFS). Solving the "Finger Count" and "Palindrome" puzzles helped me understand how to apply algorithmic logic to non-computational problems. Reviewing the Euclidean Algorithm for GCD also reminded me that some of the most efficient algorithms are also the oldest. Moving forward into Week 5, I feel confident in my ability to break down complex problems into smaller, solvable sub-problems.
Comments
Post a Comment