Project 03
Home ] Up ]

 

Course

CSIS 250-01

Semester

Spring 2001

Project Number

3

Date Assigned

February 16, 2001

Date Due

February 26, 2001

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:

  1. All the values of b[] should be in increasing order

  2. Values in a[] and b[] should be the same irrespective of the order of values and satisfy the following conditions:

                            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

Your Name

 

Main Component

Subcomponent

Max Score

Your Score

checkSorted

Description in your own words

5

 

 

Results for the three test cases

5

 

 

All the values of b[] should be in increasing order

5

 

 

size of a[] should be equal to size of b[]

5

 

 

Every value in a[] should be in b[]

5

 

 

Every value in b[] should be in a[]

5

 

 

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[])

5

 

 

Sorted a[] should be equal to b[] element by element

5

 

 

Compare and delete matching values from a[] and b[], and as a result, in the end, both a[] and b[] should be empty.

5

 

checkDistinct

Description in your own words

5

 

 

Results for the three test cases

5

 

 

For each value in a[], there should be only one matching value in d[]

5

 

 

Size of d[] should be less than or equal to size of a[]

5

 

 

There should be no duplicate value in d[]

5

 

 

Values in d[] should be in increasing order

5

 

 

For each value in d[], there should be at least one matching value in a[]

5

 

checkDistinctCount

Description in your own words

5

 

 

Results for the three test cases

5

 

 

All values in c[] are greater than 0

5

 

 

Sum of the values of c[] should be equal to the size of a[]

5

 

 

Each value d[i] should exist exactly c[i] times in a[]

5

 

 

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

5

 

Total Points

 

110