CST370 week 4

 This week was midterm prep but we also studied merge sort. Merge sort analysis is a first real application of using the Master Theorem on a divide and conquer algorithm. Merge sort works by continually dividing the array to be sorted in half, and sorting that half. Then we merge the two sorted halves by advancing a pointer on each half, coping the lowest value of either pointer to the result array and incrementing the pointer, until one half is exhausted, then we append the remainder of the sorted half to the end of the result array. The dividing is easy, and is a constant step = 1, which is the d component of the master theorem. the a is 2, because we divide both halves of the array and recurse, and the b is 2 because it's dividing by 2. I.e. T(n) = 2T(n/2) + Θ(n), which is case 2 of the Master Theorem which means merge sort is Θ(n log n). 

Comments

Popular posts from this blog

week 15-16/100

week 8/100

CST 334 Week 3 (27/100)