









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










void Mergesort (Entry theArray[], int n, int first, int last) { if(first < last) { int mid = (first + last) / 2; Mergesort (theArray, n, first, mid); Mergesort (theArray, n, mid + 1, last); Merge (theArray, n, first, mid, last); } } CPSC 223 -‐-‐ Fall 2010 3
void Merge (Entry theArray[], int n, int first, int mid, int last) { Entry tmpArray[n]; int first1 = first, first2 = mid + 1, i = first1; for(; first1 <= mid && first2 <= last; i++) { if(theArray[first1] < theArray[first2]) tmpArray[i] = theArray[first1++]; else tmpArray[i] = theArray[first2++]; } for(; first1 <= mid; i++, first1++) // copy remaining from first half tmpArray[i] = theArray[first1]; for(; first2 <= last; i++, first2++) // copy remaining from sec. half tmpArray[i] = theArray[first2]; for(int j = first; j <= last; j++) // copy tmpArray to the array theArray[j] = tmpArray[j]; } CPSC 223 -‐-‐ Fall 2010 4
CPSC 223 -‐-‐ Fall 2010 7 B R V S C For example, inheritance hierarchies (taxonomies, ontologies, …) M Vehicle Bicycle Mountain Bike Road Bike Car Sports Car ÷ 2
5 Algebraic expressions (evaluaVon order) × 3 4
CPSC 223 -‐-‐ Fall 2010 8 E Y C G N NesVng (including “has a” relaVonships) N Company Employee Name #Years Name Gonzaga J John 15 Sort order A B C D E F G
CPSC 223 -‐-‐ Fall 2010 22
CPSC 223 -‐-‐ Fall 2010 26 D B G A C E H F
CPSC 223 -‐-‐ Fall 2010 27 D B G A C E H F
CPSC 223 -‐-‐ Fall 2010 28 A B C D E F G