CST370 - Week 4

 CST370 Week 4

This week is a short week due to midterms. We learned about merge sort, which uses the divide-and-conquer method. Merge sort goes through these steps:
  1. Split the original array into two halves, until each individual element is by itself.
  2. Sort the first half recursively
  3. Sort the second half recursively
  4. Merge the two halves together:
    1. Compare the first elements of each half
    2. Push smaller element to a new result array
    3. Increment index of half that pushed the smaller element
    4. (Repeat Steps 1-3 until all elements are sorted)
For Master Theorem, the time complexity of merge sort is θ [n*log(n)]. There are two recursive calls, so a = 2, the input size divides by 2 each time, so b = 2, and since the number of comparisons is n, (n^d) = (n^1) => d = 1.

I wanted to understand how to derive the Master Theorem from pseudocode, so I looked up some practice exercises online, but there is very little found for it. I decided to get the textbook because I need more exercises to understand the concepts presented in class.
Isopod Update: The trichorhina tomentosas are back.

Comments

Popular posts from this blog

CST300 - Week 4

CST334 - Week 6

CST334 - Week 5