|
Write (in Microsoft Word) and print three detailed algorithms for the three preliminary algorithms given below and explained in the class. Each algorithm should include the following items: a. A brief description describing the purpose of the algorithm b. Detailed algorithm c. Results of your algorithm for the three test cases Test your algorithms for the following cases: Test case 1: a[7] = {60, 10, 20, 10, 30, 60, 10} b[7] = {10, 10, 10, 20, 30, 60, 60} d[4] = {10, 20, 30, 60} c[4] = { 3, 1, 1, 2} Test case 2: a[9] = {60, 10, 20, 10, 20, 25, 30, 60, 10} b[9] = {10, 10, 10, 20, 20, 25, 30, 60, 60} d[5] = {10, 20, 25, 30, 60} c[5] = { 3, 2, 1, 1, 2} Test case 3: a[9] = {60, 10, 20, 10, 20, 25, 30, 60, 10} b[9] = {10, 10, 10, 20, 20, 30, 30, 60, 60} d[5] = {10, 20, 25, 30, 60} c[5] = { 3, 1, 2, 1, 2} checkSorted (a[], b[]) For a[] as the original list check that b[] is holding the sorted values of a[]. In other words, check that all the values in b[] are in increasing order from a[]. Following conditions should be satisfied:
a. size of a[] should be equal to size of b[] b. Every value in a[] should be in b[] c. Every value in b[] should be in a[] d. sum(a[]) should be sum(b[]) or for some other function f applied on a[] and b[], f(a[]) should be equal to f(b[]) e. Sorted a[] should be equal to b[] element by element f. Compare and delete matching values from a[] and b[], and as a result, in the end, both a[] and b[] should be empty. checkDistinct(a[], d[]) Array d[] should have all the distinct values of array a[] in increasing order and satisfy the following conditions: 1. For each value in a[], there should be only one matching value in d[] 2. Size of d[] should be less than or equal to size of a[] 3. There should be no duplicate value in d[] 4. Values in d[] should be in increasing order 5. For each value in d[], there should be at least one matching value in a[] checkDistinctCount(a[], d[], c[]) d[] and c[] should represent distinct values and their counts of values from array a[] and satisfy the following conditions: 1. All values in c[] are greater than 0 2. Sum of the values of c[] should be equal to the size of a[] 3. Each value d[i] should exist exactly c[i] times in a[] 4. If a new array e[] is generated from d[] and c[] where a value d[i] repeats c[i] times, then e[] and a[] should hold the same values irrespective of their order Self-Evaluation Sheet
|