/5031-hw4

fourth homework assignment for algorithm

Primary LanguageC#MIT LicenseMIT

Homework #4

Part 1: MergeSort

Implement MergeSort per the algorithm shown in class (and in the textbook) to sort an array A in ascending order. Here are the test cases you should include:

Test Case # Array
1 { }
2 {0, 1, 2, 3}
3 {0, 1, 2, 3, 4}
4 {3, 1, 4, 1, 5, 9, 2, 6, 5}
5 {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}

Part 2: Test cases

Having good test cases is very important when writing code. Good test cases not only test the “happy path” of your code, but also test the boundary conditions where things can get strange. Of the 5 test cases shown above, only #5 specifically tests the “happy path”. The rest test boundaries. Answer these questions in your homework submission:

  1. Why is test case #1 important?
  2. What’s the key difference between test cases #2 and #3? Why is this important when testing MergeSort?
  3. Test case #4 is some digits of π. What else is important about test case #4?