+ All Categories
Home > Documents > The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse,...

The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse,...

Date post: 24-Dec-2015
Category:
Upload: cassandra-harper
View: 215 times
Download: 2 times
Share this document with a friend
Popular Tags:
39
The The Amazing Amazing Year: Year: Münster (Germany), Münster (Germany), Covington (KY), Covington (KY), Bethlehem (PA), and Bethlehem (PA), and Huntingdon Huntingdon Gerald Kruse, Ph.D. Gerald Kruse, Ph.D. Associate Professor of Computer Associate Professor of Computer Science and Mathematics Science and Mathematics [email protected] http://faculty.juniata.edu/kruse http://faculty.juniata.edu/kruse
Transcript
Page 1: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

The The AmazingAmazing Year: Year:Münster (Germany), Covington Münster (Germany), Covington

(KY), Bethlehem (PA), and (KY), Bethlehem (PA), and HuntingdonHuntingdon

Gerald Kruse, Ph.D.Gerald Kruse, Ph.D.Associate Professor of Computer Science Associate Professor of Computer Science

and Mathematicsand Mathematics

[email protected]://faculty.juniata.edu/krusehttp://faculty.juniata.edu/kruse

Page 2: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

2006-072006-07Faculty Exchange at Fachhochschule (FH) Münster, during the fall Faculty Exchange at Fachhochschule (FH) Münster, during the fall 2006 semester.2006 semester.

Note: Note: FH-M is also known as the Münster University of Applied FH-M is also known as the Münster University of Applied Sciences, or MUAS. It’s Engineering and Technology campus is Sciences, or MUAS. It’s Engineering and Technology campus is located in Burgsteinfurt, about 30 miles outside Münster.located in Burgsteinfurt, about 30 miles outside Münster.

Taught Taught Algorithmen und Data StrukturenAlgorithmen und Data Strukturen… aka Algorithms and Data … aka Algorithms and Data Structures. It is between Juniata’s “CS 2” (CS 240) and Structures. It is between Juniata’s “CS 2” (CS 240) and “Algorithms,” CS 315.“Algorithms,” CS 315.

Taught Taught Graphical ProgrammingGraphical Programming, an one-semester course in , an one-semester course in Computer Graphics.Computer Graphics.

Sabbatical in Huntingdon, PA, during the spring 2007 semester, Sabbatical in Huntingdon, PA, during the spring 2007 semester, exploring modifications to MA 103, Quantitative Methods.exploring modifications to MA 103, Quantitative Methods.

Page 3: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Some mathematics…Some mathematics…

Let:Let:

FF = one semester faculty exchange = one semester faculty exchange

SS = one semester sabbatical = one semester sabbatical

PP = full pay for an academic year = full pay for an academic year

F + S F + S = = PP

Page 4: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

We hope to encourage Juniata We hope to encourage Juniata students to study at FH-Münster by students to study at FH-Münster by

having a faculty exchange firsthaving a faculty exchange firstFacultyFaculty

Gerald Kruse Thomas WeikGerald Kruse Thomas Weik

Juniata StudentsJuniata Students FH-Münster StudentsFH-Münster StudentsTim Auman, Mike LinkTim Auman, Mike Link Robin Segglemann, Frank Volkmer Robin Segglemann, Frank Volkmer

Sascha Hlusiak, Morin OstkampSascha Hlusiak, Morin Ostkamp

Moritz Prinz, Thomas BeermanMoritz Prinz, Thomas Beerman

Page 5: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Departing Huntingdon on the TrainDeparting Huntingdon on the Train

Page 6: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

““Our” House in the Village of LeerOur” House in the Village of Leer

Page 7: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Riding Bikes into the Village of LeerRiding Bikes into the Village of Leer

Page 8: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

First Day of “Grundschule”First Day of “Grundschule”

Page 9: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Fuchsjagd (or “Foxhunt” in English)Fuchsjagd (or “Foxhunt” in English)

Page 10: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

St. NicholasSt. Nicholas

Page 11: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

To read more about our travel To read more about our travel exploits…exploits…

http://kruse5.blogspot.com

If you read our travel blog, you will have the following questions If you read our travel blog, you will have the following questions answered:answered:

1. Is it a good idea to have non-prescription medical supplements 1. Is it a good idea to have non-prescription medical supplements shipped from the United States to Germany?shipped from the United States to Germany?

2. Can you get a speeding ticket on the autobahn?2. Can you get a speeding ticket on the autobahn?

3. How bad is “3. How bad is “inadvertentlyinadvertently” using Juniata’s Pcard to purchase ” using Juniata’s Pcard to purchase tickets at Legoland ?tickets at Legoland ?

4. What percentage of Germans visit Majorca?4. What percentage of Germans visit Majorca?

Page 12: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Juniata Students For DinnerJuniata Students For Dinner

Page 13: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

A Day in the LifeA Day in the Life

Monday, Tuesday, and WednesdayMonday, Tuesday, and Wednesday06:37 Bus from Leer to Burgsteinfurt06:37 Bus from Leer to BurgsteinfurtLecture from 08:00 to 09:45Lecture from 08:00 to 09:45Lab from 10:00 to 13:00Lab from 10:00 to 13:0014:51 Bus from Burgsteinfurt to Leer14:51 Bus from Burgsteinfurt to Leer

Thursday and FridayThursday and FridayBreakfast for the familyBreakfast for the family08:37 Bus from Leer to Burgsteinfurt08:37 Bus from Leer to BurgsteinfurtCourse prep, research, etc.Course prep, research, etc.13:51 Bus from Burgsteinfurt to Leer13:51 Bus from Burgsteinfurt to Leer

Afternoon Activities with the Family:Afternoon Activities with the Family:Sporthalle, Horseback Riding, Bike Rides, FußballSporthalle, Horseback Riding, Bike Rides, Fußball

Page 14: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

The Computer LabThe Computer Lab

Page 15: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Observations and ReflectionsObservations and Reflections

Very little homework to grade…Very little homework to grade…

If the student completes all labs, they are, eligible to take If the student completes all labs, they are, eligible to take the final examthe final exam

The students were amazingThe students were amazing

No committee work, a little advisingNo committee work, a little advising

Web-based (foreshadowing to sabbatical)Web-based (foreshadowing to sabbatical)

““Psst, don’t share this with my colleagues at Juniata, they Psst, don’t share this with my colleagues at Juniata, they might be jealous…”might be jealous…”

Page 16: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

The Perfect StormThe Perfect Storm

Unscheduled time at the end of the weekUnscheduled time at the end of the week

An Algorithms course filled with eager An Algorithms course filled with eager students, who happen to use a variety of students, who happen to use a variety of computers and compilerscomputers and compilers

A troublesome/intriguing timing resultA troublesome/intriguing timing result

A problem with a pleasing blend of A problem with a pleasing blend of Mathematics and Computer ScienceMathematics and Computer Science

Page 17: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

How Fast is my Sorting Algorithm?How Fast is my Sorting Algorithm?

The The Sorting ProblemSorting Problem, from Cormen et. al. , from Cormen et. al. Input: Input: A sequence of n numbers, (aA sequence of n numbers, (a11, a, a22, … a, … ann))

Output:Output: A permutation (reordering) (a A permutation (reordering) (a11’, a’, a22’, … a’, … ann’) of the input sequence ’) of the input sequence such that asuch that a11’ ’ ≤≤ a a22’ ’ ≤≤ … … ≤≤ a ann’’

Note: This definition can be expanded to include sorting primitive data such Note: This definition can be expanded to include sorting primitive data such as characters or strings, alpha-numeric data, and data records with key as characters or strings, alpha-numeric data, and data records with key values.values.

Sorting algorithms are analyzed using many different metrics: Sorting algorithms are analyzed using many different metrics: expected run-time, memory usage, communication bandwidth, expected run-time, memory usage, communication bandwidth, implementation complexity, … we chose expected run-timeimplementation complexity, … we chose expected run-time

Expected running time is given using “Big-O” notationExpected running time is given using “Big-O” notationOO( g(( g(nn) ) = { f() ) = { f(nn): pos. constants ): pos. constants cc and and nn00 s.t. 0 s.t. 0 ≤ ≤ f(f(nn) ) ≤ ≤ cc*g(*g(nn) ) nn ≥≥ nn00 }. }.

While While OO-notation describes an asymptotic upper bound on a function, it is -notation describes an asymptotic upper bound on a function, it is frequently used to describe asymptotically tight bounds.frequently used to describe asymptotically tight bounds.

Page 18: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Conceptually, a Conceptually, a heapheap can be thought of as a complete can be thought of as a complete binary tree:binary tree:

HeapsHeaps

16

14 10

8 7 9 3

2 4 1

Page 19: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Conceptually, a Conceptually, a heapheap can be thought of as a complete can be thought of as a complete binary tree:binary tree:

HeapsHeaps

16

14 10

8 7 9 3

2 4 1

But in practice, heaps are usually implemented as arrays.But in practice, heaps are usually implemented as arrays.

Notice how 8, 2, and 4 are near each other in the tree, but relatively far Notice how 8, 2, and 4 are near each other in the tree, but relatively far apart in the array…apart in the array…

By the wayBy the way, e-Bay uses a “heap-like” data structure to track bids., e-Bay uses a “heap-like” data structure to track bids.

16 14 10 8 7 9 3 2 4 1A =

Page 20: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

HeapsortHeapsortHeapsort(A)Heapsort(A)

{{

BuildHeap(A);BuildHeap(A);

for (i = length(A) downto 2)for (i = length(A) downto 2)

{{

Swap(A[1], A[i]);Swap(A[1], A[i]);

heap_size(A) -= 1;heap_size(A) -= 1;

Heapify(A, 1);Heapify(A, 1);

}}

}}When the heap property is violated at just one node (which has sub-When the heap property is violated at just one node (which has sub-trees which are valid heaps), trees which are valid heaps), HeapifyHeapify “floats down” the parent node to “floats down” the parent node to fix the heap. Remembering the tree structure of the heap, each fix the heap. Remembering the tree structure of the heap, each HeapifyHeapify call takes O(lg call takes O(lg nn) time. ) time.

Since there are Since there are nn – 1 calls to – 1 calls to HeapifyHeapify, Heapsort’s expected execution , Heapsort’s expected execution time is O(time is O(nn lg lg nn), just like Quicksort.), just like Quicksort.

Page 21: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Timing ResultsTiming Results

Ratio Test for Heapsort

0.000000020

0.000000025

0.000000030

0.000000035

0.000000040

0.000000045

0 500000 1000000 1500000 2000000

Input Size, n

T(n)

/ (n

*lg

n)

Win/Rec/C++/Ox Win/Rec/C++/O2

Page 22: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Counting ComparisonsCounting Comparisons

Ratio Test for Heapsort w/Number of Key Comparisons

1.80

1.85

1.90

1.95

2.00

0 500000 1000000 1500000 2000000 2500000 3000000 3500000 4000000

Input Size, n

# co

mp

/ (n

*lg

n)

Win/Rec/C++ Win/Seq/C

Page 23: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

A Useful Case-Study in Algorithmic Experimentation: Unexpected Timing Results for HeapsortDr. Gerald Kruse, Ph.D.

Associate Professor of Mathematics and Computer Science / Information TechnologyJuniata College, Huntingdon, Pennsylvania, USA

A Useful Case-Study in Algorithmic Experimentation: Unexpected Timing Results for HeapsortDr. Gerald Kruse, Ph.D.

Associate Professor of Mathematics and Computer Science / Information TechnologyJuniata College, Huntingdon, Pennsylvania, USA

IntroductionThe study of algorithms, and sorting algorithms in particular, is in the core of the Computer Science curriculum. Detailed asymptotic analysis of the classic sorting algorithms is typically the first in-depth exposure of a student to Big-Oh notation. It is instructive for students to implement these sorting algorithms and experimentally confirm their theoretically derived asymptotic behavior. Heapsort is a well-known sorting algorithm and it has O(n*lg n) expected asymptotic performance. However, its implementation may generate unexpected results. Interestingly, the ratio of the expected running time to the actual running time should converge to a constant as n increases, however occasionally it does not. Timing an implementation of Heapsort for a range of problem sizes and data values can reveal compiler idiosyncrasies and difficulties with large input.

IntroductionThe study of algorithms, and sorting algorithms in particular, is in the core of the Computer Science curriculum. Detailed asymptotic analysis of the classic sorting algorithms is typically the first in-depth exposure of a student to Big-Oh notation. It is instructive for students to implement these sorting algorithms and experimentally confirm their theoretically derived asymptotic behavior. Heapsort is a well-known sorting algorithm and it has O(n*lg n) expected asymptotic performance. However, its implementation may generate unexpected results. Interestingly, the ratio of the expected running time to the actual running time should converge to a constant as n increases, however occasionally it does not. Timing an implementation of Heapsort for a range of problem sizes and data values can reveal compiler idiosyncrasies and difficulties with large input.

References“Computing Curricula 2001: Computer Science,” a joint report from IEEE – Computer Society and the Association for Computing Machinery.T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, “Introduction to Algorithms, Second Edition,” Cambridge, MA/London, England: The MIT Press/McGraw-Hill, 2003.N. Dale, C. Weems, D. T. Joyce, “Object-Oriented Data Structures Using Java,” Boston, MA: Jones and Bartlett, 2002.M. T. Goodrich and R. Tamassia, “Algorithm Design: Foundation, Analysis, and Internet Examples,” Wiley: New York: 2001.D. E. Knuth, “The Art of Computer Programming, Volume 3: (Second Edition) Sorting and Searching,” Addison-Wesley-Longman: Redwood City, CA, 1998.C. C. McGeoch, “Analyzing algorithms by simulation: Variance reduction techniques and simulation speedups,” ACM Computing Surveys, vol. 24, no. 2, pp. 195 – 212, 1992.C. C. McGeoch, D. Precup, and P. R. Cohen, “How to find the Big-Oh of your data set (and how not to),” Advances in Intelligent Data Analysis, vol. 1280 of Lecture Notes in Computer Science, pp. 41 – 52, Springer-Verlag, 1997.R. Sedgewick, “Algorithms in C, Parts 1-4: Fundamentals, Data Structures, Sorting, Searching, Third Edition,” Addison-Wesley: Boston, MA, 1997

References“Computing Curricula 2001: Computer Science,” a joint report from IEEE – Computer Society and the Association for Computing Machinery.T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, “Introduction to Algorithms, Second Edition,” Cambridge, MA/London, England: The MIT Press/McGraw-Hill, 2003.N. Dale, C. Weems, D. T. Joyce, “Object-Oriented Data Structures Using Java,” Boston, MA: Jones and Bartlett, 2002.M. T. Goodrich and R. Tamassia, “Algorithm Design: Foundation, Analysis, and Internet Examples,” Wiley: New York: 2001.D. E. Knuth, “The Art of Computer Programming, Volume 3: (Second Edition) Sorting and Searching,” Addison-Wesley-Longman: Redwood City, CA, 1998.C. C. McGeoch, “Analyzing algorithms by simulation: Variance reduction techniques and simulation speedups,” ACM Computing Surveys, vol. 24, no. 2, pp. 195 – 212, 1992.C. C. McGeoch, D. Precup, and P. R. Cohen, “How to find the Big-Oh of your data set (and how not to),” Advances in Intelligent Data Analysis, vol. 1280 of Lecture Notes in Computer Science, pp. 41 – 52, Springer-Verlag, 1997.R. Sedgewick, “Algorithms in C, Parts 1-4: Fundamentals, Data Structures, Sorting, Searching, Third Edition,” Addison-Wesley: Boston, MA, 1997

Sequential Heapsort (in C), from Sedgewick’s textfixDown(Item a[], int k, int N){

int j;while (2*k <= N){

j = 2*k;if (j < N && less(a[j], a[j+1])) j+

+;if (!less(a[k], a[j])) break;exch(a[k], a[j]); k = j;

}}#define pq(A) a[l-1+A]void heapsort(Item a[], int l, int r){

int k, N = r-l+1;for (k = N/2; k >= 1; k--) fixDown(&pq(0), k, N);while (N > 1) { exch(pq(1), pq(N)); fixDown(&pq(0), 1, --N); }

}

Sequential Heapsort (in C), from Sedgewick’s textfixDown(Item a[], int k, int N){

int j;while (2*k <= N){

j = 2*k;if (j < N && less(a[j], a[j+1])) j+

+;if (!less(a[k], a[j])) break;exch(a[k], a[j]); k = j;

}}#define pq(A) a[l-1+A]void heapsort(Item a[], int l, int r){

int k, N = r-l+1;for (k = N/2; k >= 1; k--) fixDown(&pq(0), k, N);while (N > 1) { exch(pq(1), pq(N)); fixDown(&pq(0), 1, --N); }

}

The ExperimentFill the unsorted array with random double valuesfor (i=1; i<=N; i++) { unsortedArray[i] = (double)rand(); }

Time the loop which copies and sorts for each of numIter iterationsstart = clock();for (j=0; j<numIter; j++) {

for (i=1; i<=N; i++) a[i] = unsortedArray[i];heapsort();

}finish = clock();sort_with_copy = (double(finish)-double(start))/CLOCKS_PER_SEC;

Time the loop which only copies for each of numIter iterationsstart = clock();for (j=0; j<numIter; j++) { for (i=1; i<=N; i++) a[i] = unsortedArray[i]; }finish = clock();copy_only = (double(finish)-double(start))/CLOCKS_PER_SEC;

Calculate the time to sort the array once sort_time = (sort_with_copy - copy_only)/numIter;

The ExperimentFill the unsorted array with random double valuesfor (i=1; i<=N; i++) { unsortedArray[i] = (double)rand(); }

Time the loop which copies and sorts for each of numIter iterationsstart = clock();for (j=0; j<numIter; j++) {

for (i=1; i<=N; i++) a[i] = unsortedArray[i];heapsort();

}finish = clock();sort_with_copy = (double(finish)-double(start))/CLOCKS_PER_SEC;

Time the loop which only copies for each of numIter iterationsstart = clock();for (j=0; j<numIter; j++) { for (i=1; i<=N; i++) a[i] = unsortedArray[i]; }finish = clock();copy_only = (double(finish)-double(start))/CLOCKS_PER_SEC;

Calculate the time to sort the array once sort_time = (sort_with_copy - copy_only)/numIter;

Recursive Heapsort (in C++), from Cormen, et. al. textvoid maxheapify(int i){

int l, r, largest; double temp;l = left(i); r = right(i);if (l<=heapsize && a[l]>a[i]) { largest = l; } else { largest =

i; }if (r<=heapsize && a[r]>a[largest]) largest = r;if (largest !=i) exch(a[i] , a[largest]);

}void buildheap(){

int i;heapsize = N;for (i=heapsize/2; i>=1; i--) maxheapify(i);

}void heapsort(){

int i; double temp;buildheap();for (i=N; i>=2; i--){

exch(a[i] , a[largest]);heapsize--;maxheapify(1);

}}

Recursive Heapsort (in C++), from Cormen, et. al. textvoid maxheapify(int i){

int l, r, largest; double temp;l = left(i); r = right(i);if (l<=heapsize && a[l]>a[i]) { largest = l; } else { largest =

i; }if (r<=heapsize && a[r]>a[largest]) largest = r;if (largest !=i) exch(a[i] , a[largest]);

}void buildheap(){

int i;heapsize = N;for (i=heapsize/2; i>=1; i--) maxheapify(i);

}void heapsort(){

int i; double temp;buildheap();for (i=N; i>=2; i--){

exch(a[i] , a[largest]);heapsize--;maxheapify(1);

}}

Suggestions for Use as a Case-Study1. Have the students implement and time several sorts, with a variety of data (ascending, descending, random).2. Give the students time in class, preferably in a lab, working with the test driver. This helps promote the significance of calling the sort multiple times, as well as copying the unsorted data into the structure to be sorted before each sort.3. Encourage the “open-endedness” of this type of study. My assignments typically specify that students must explore some additional factors beyond the standard “best-case” and “worst-case” data. At various points during lecture I typically suggest possible topics for the students to pursue.4. I still don’t have a definitive answer for the growth in the Heapsort ratio using running time. Have any of you encountered the same results?

Suggestions for Use as a Case-Study1. Have the students implement and time several sorts, with a variety of data (ascending, descending, random).2. Give the students time in class, preferably in a lab, working with the test driver. This helps promote the significance of calling the sort multiple times, as well as copying the unsorted data into the structure to be sorted before each sort.3. Encourage the “open-endedness” of this type of study. My assignments typically specify that students must explore some additional factors beyond the standard “best-case” and “worst-case” data. At various points during lecture I typically suggest possible topics for the students to pursue.4. I still don’t have a definitive answer for the growth in the Heapsort ratio using running time. Have any of you encountered the same results?

Analyzing Timing Results Using the Ratio-TestHere we are attempting to verify previously derived expected asymptotic behavior. This is a much simpler problem than attempting to experimentally determine asymptotic behavior.Since we know the expected running time of Heapsort, we simply plot the ratio of the actual running time, T(n) to this expected running time, n*lg n. If this ratio converges to a constant, we can conclude that our implementation exhibits the theoretical expected running time [McGeoch (2)].The both the recursive and sequential versions of the Heapsort algorithm were implemented in C, C++, and Java, on the Windows and Unix/Solaris operating systems. In addition, various levels of compiler optimizations were tested.

Analyzing Timing Results Using the Ratio-TestHere we are attempting to verify previously derived expected asymptotic behavior. This is a much simpler problem than attempting to experimentally determine asymptotic behavior.Since we know the expected running time of Heapsort, we simply plot the ratio of the actual running time, T(n) to this expected running time, n*lg n. If this ratio converges to a constant, we can conclude that our implementation exhibits the theoretical expected running time [McGeoch (2)].The both the recursive and sequential versions of the Heapsort algorithm were implemented in C, C++, and Java, on the Windows and Unix/Solaris operating systems. In addition, various levels of compiler optimizations were tested.

For all these experiments, the ratios are clearly increasing, rather than approaching a constant value. Why? For dramatically large n we could attribute this to the data being “out-of-core” memory. The increase in ratio for these relatively small values of n is probably also explained as being caused by cache memory effects. It is interesting to note that this happens irregardless of platform, language, or version of the Heapsort algorithm.

For all these experiments, the ratios are clearly increasing, rather than approaching a constant value. Why? For dramatically large n we could attribute this to the data being “out-of-core” memory. The increase in ratio for these relatively small values of n is probably also explained as being caused by cache memory effects. It is interesting to note that this happens irregardless of platform, language, or version of the Heapsort algorithm.

Ratio Test for HeapsortWindows Recursive C++ .NET \Ox and \O2

0.000000020

0.000000025

0.000000030

0.000000035

0.000000040

0.000000045

0 500000 1000000 1500000 2000000

Input Size, n

T(n

) / (

n*l

g n

)

Win/Rec/C++/Ox Win/Rec/C++/O2

Ratio Test for HeapsortWindows Sequential C.NET No Opt and \Ox

0

0.00000001

0.00000002

0.00000003

0.00000004

0.00000005

0.00000006

0.00000007

0.00000008

0 500000 1000000 1500000 2000000 2500000

Input Size, n

T(n

) / (

n*l

g n

)

Win/Seq/C/No Opt Win/Seq/C/Ox

Ratio Test for HeapsortSolaris Recursive(2) Java

0.00015

0.00016

0.00017

0.00018

0.00019

0.00020

0.00021

0.00022

0.00023

0 500000 1000000 1500000 2000000

Input Size, n

T(n

) / (

n*l

g n

)

Solaris/Rec/Java Solaris/Rec(2)/Java

)lg(*

)(

nn

nT

So, is Heapsort really O(n*lg n) ?Yes.We demonstrate this in the following graph, where rather than measuring running time, T(n), the number of key comparisons were counted. The ratio plotted is therefore:

# comparisons / (n*lg n)The ratios here do appear to converge to a constant as n increases.

So, is Heapsort really O(n*lg n) ?Yes.We demonstrate this in the following graph, where rather than measuring running time, T(n), the number of key comparisons were counted. The ratio plotted is therefore:

# comparisons / (n*lg n)The ratios here do appear to converge to a constant as n increases.

Ratio Test for Heapsort w/Number of Key Comparisons

1.80

1.85

1.90

1.95

2.00

0 500000 1000000 1500000 2000000 2500000 3000000 3500000 4000000

Input Size, n

# co

mp

/ (n

*lg

n)

Win/Rec/C++ Win/Seq/C

Page 24: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Future WorkFuture Work

For very large For very large nn, we would expect a slowdown for ANY algorithm as , we would expect a slowdown for ANY algorithm as the data no longer fits in memory, but it would look like a step function at the data no longer fits in memory, but it would look like a step function at each layer of memory, not the gradual growth Heapsort exhibits.each layer of memory, not the gradual growth Heapsort exhibits.

Consider the memory access patterns of Heapsort, and attempt to Consider the memory access patterns of Heapsort, and attempt to understand, and possibly simplify, the mathematic characterization.understand, and possibly simplify, the mathematic characterization.

No one has really “fixed” the algorithm, either.No one has really “fixed” the algorithm, either.

Explore modifications to the RAM model used in theoretical analysisExplore modifications to the RAM model used in theoretical analysis

This is a fun exploration for students, appealing to those with an This is a fun exploration for students, appealing to those with an interest in the mathematics or computer science , look to expand into a interest in the mathematics or computer science , look to expand into a student research projectstudent research project

Page 25: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Quantitative Literacy at JuniataQuantitative Literacy at JuniataJuniata has had “Quant-Math” and “Quant-Stat” skill Juniata has had “Quant-Math” and “Quant-Stat” skill requirement for graduation since the mid-1990’s.requirement for graduation since the mid-1990’s.

From the Juniata Catalog:From the Juniata Catalog:

Quantitative SkillsQuantitative Skills

To demonstrate quantitative literacy, students have three To demonstrate quantitative literacy, students have three options:options:

(1) complete a "Q" course;(1) complete a "Q" course;

(2) complete a mathematical course (QM) and a (2) complete a mathematical course (QM) and a statistics course (QS);statistics course (QS);

(3) pass a proficiency exam. (3) pass a proficiency exam.

Page 26: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Oh, and just what is Quantitative Oh, and just what is Quantitative Literacy?Literacy?

““The ability to use numbers and data analysis in The ability to use numbers and data analysis in everyday life.”everyday life.” Bernard Madison, Univ. of Arkansas Bernard Madison, Univ. of Arkansas

““..knowing how to reason and think, and it is all but ..knowing how to reason and think, and it is all but absent from our curricula today.”absent from our curricula today.” Gina Kolata, NY Times Gina Kolata, NY Times

““Having comfort with arithmetic, data analysis, Having comfort with arithmetic, data analysis, computing, modeling, statistics, chance/probability, and computing, modeling, statistics, chance/probability, and reasoning.” reasoning.” Excerpt from Excerpt from Mathematics in DemocracyMathematics in Democracy..

While a course in quantitative literacy might focus on While a course in quantitative literacy might focus on practical, real-world problems, it still provides the students practical, real-world problems, it still provides the students with a strong mathematical foundation.with a strong mathematical foundation.

Page 27: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

MA 103, Quantitative Methods, aka MA 103, Quantitative Methods, aka “QM”“QM”

MA 103, Quantitative Methods, was developed by MA 103, Quantitative Methods, was developed by Sue Esch to serve students who do not have Sue Esch to serve students who do not have courses with quantitative components in their courses with quantitative components in their POE’s.POE’s.

MA 103 is one of the few courses which satisfies MA 103 is one of the few courses which satisfies both the “QM” and “QS” skills.both the “QM” and “QS” skills.

A large percentage of students at Juniata satisfy A large percentage of students at Juniata satisfy their “Q” graduation requirement by taking MA 103, their “Q” graduation requirement by taking MA 103, Quantitative Methods (5 sections per year).Quantitative Methods (5 sections per year).

Page 28: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Time for a change…Time for a change…

From 1996 to 2007, the text used in MA 103 was From 1996 to 2007, the text used in MA 103 was Quantitative MethodsQuantitative Methods, notes written and , notes written and maintainedmaintained by Sue Esch (Bukowski and Kruse by Sue Esch (Bukowski and Kruse added as co-authors later), and produced on added as co-authors later), and produced on campus.campus.

Students used two full-feature software Students used two full-feature software packages: Minitab for statistics, and Maple for packages: Minitab for statistics, and Maple for mathematics.mathematics. MA 103 was one of my favorite courses to teach, MA 103 was one of my favorite courses to teach, but I realized that after 10 years it was due for but I realized that after 10 years it was due for an update.an update.

Page 29: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Search ParametersSearch ParametersPublished texts preferredPublished texts preferred

Excel-based technology preferredExcel-based technology preferred

Activity-basedActivity-based

Many texts considered, three seriouslyMany texts considered, three seriously

Frequent consultation with Math department Frequent consultation with Math department colleaguescolleagues

Page 30: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

And the Winner Is…And the Winner Is…

Chosen Text: Quantitative Reasoning, by Alicia Sevilla and Kay Somers, from Moravian College.

Page 31: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Textbook HighlightsTextbook Highlights

Active learning approachActive learning approach

Technology informs and enhances the mathTechnology informs and enhances the math

Modules on Apportionment and Conditional ProbabilityModules on Apportionment and Conditional Probability

Fall 2007 Student Comment Regarding the Textbook:Fall 2007 Student Comment Regarding the Textbook:““Despite being outside my major and one of those required courses Despite being outside my major and one of those required courses people are supposed to hate, I loved this course… The textbook for people are supposed to hate, I loved this course… The textbook for the course was one of the best I've had at the school -- it was easy the course was one of the best I've had at the school -- it was easy to understand, concise, and the assignments taught the material to understand, concise, and the assignments taught the material well.”well.”

Page 32: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

MAA PREP Workshop at MAA PREP Workshop at MoravianMoravian

Shared all my course materialsShared all my course materials

http://www.moravian.edu/QRPREP/photos.html

Page 33: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Course HighlightsCourse HighlightsPre- and post-assessments of student skills and Pre- and post-assessments of student skills and attitudes attitudes Open-ended projectsOpen-ended projectsPaper-reduced (assignments posted online, deliverables Paper-reduced (assignments posted online, deliverables uploaded)uploaded)Provided my Math department colleagues with:Provided my Math department colleagues with: daily schedule daily schedule daily notes daily notes suggested homework problems suggested homework problems solutions to all Activities solutions to all ActivitiesWeb-site evaluation module with Reference LibrarianWeb-site evaluation module with Reference LibrarianCourse web-site:Course web-site:http://faculty.juniata.edu/kruse/ma103/ma103s08syl.htm

Page 34: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Fall 2007 CommentsFall 2007 Comments““I feel that the methods used in this course were very I feel that the methods used in this course were very

effective in teaching the course subject matter. Using effective in teaching the course subject matter. Using class time for both lecture and working on assignments class time for both lecture and working on assignments was great - we apply what we learned right away and was great - we apply what we learned right away and help was readily available when we needed it.”help was readily available when we needed it.”

  

““I thought that the instruction and layout for this course I thought that the instruction and layout for this course were excellent. I was very nervous about taking a math were excellent. I was very nervous about taking a math course, and I had heard bad things about QM from past course, and I had heard bad things about QM from past students, but it must be the fact that the course was students, but it must be the fact that the course was revamped that made it so much better.”revamped that made it so much better.”

  

““I really liked political psychology…”I really liked political psychology…”

Page 35: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Fall 2007 Comments, cont.Fall 2007 Comments, cont.““This was a very good class for me. I am not very confident This was a very good class for me. I am not very confident

in my math abilities and this class was a nice way for me in my math abilities and this class was a nice way for me to gradually get into college level math. This class did to gradually get into college level math. This class did (not)(not) cause any really serious stress…”cause any really serious stress…”

  

““I think that this course was really good. Math is not really I think that this course was really good. Math is not really my favorite subject and I was a little disappointed that I my favorite subject and I was a little disappointed that I would have to take one for the FISHN requirements, but would have to take one for the FISHN requirements, but Professor Kruse did an excellent job. I really feel like I Professor Kruse did an excellent job. I really feel like I learned a lot of valuable things in his class and he made learned a lot of valuable things in his class and he made math really fun. Instead of it being numbers and ideas math really fun. Instead of it being numbers and ideas that I felt like I would never use, I feel like I can take and that I felt like I would never use, I feel like I can take and apply everything he taught us to real life.”apply everything he taught us to real life.”

Page 36: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Additional AccomplishmentsAdditional AccomplishmentsAt-large member of International Education At-large member of International Education CommitteeCommittee

FH-Muenster Kolloquium: “Google’s Billion FH-Muenster Kolloquium: “Google’s Billion Dollar Eigenvector”Dollar Eigenvector”

SIGCSE Special Session: “A Status Report from SIGCSE Special Session: “A Status Report from the Committee to Evaluate Models of Faculty the Committee to Evaluate Models of Faculty Scholarship”Scholarship”

MAA (Allegheny Mountain Section) Talk: “Are MAA (Allegheny Mountain Section) Talk: “Are Quicksort and Heapsort Really O(n*lg n)?”Quicksort and Heapsort Really O(n*lg n)?”

Page 37: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Additional Accomplishments IIAdditional Accomplishments II““Published” in si.com:Published” in si.com:

Jerry of Huntingdon, Pa.Jerry of Huntingdon, Pa.,,Has presented Andrew with such a lengthy resume that the head of ourHas presented Andrew with such a lengthy resume that the head of our

department wanted to hire him. No, Jerry says, just answer one question fordepartment wanted to hire him. No, Jerry says, just answer one question for

me. And what might that be, your Lordship? Will everyone look at what Indy didme. And what might that be, your Lordship? Will everyone look at what Indy did

to the Bears in the Super Bowl, which seemed to mirror what Arizona did toto the Bears in the Super Bowl, which seemed to mirror what Arizona did to

them, which is attacking the Tampa Two defense with underneath stuff, and gothem, which is attacking the Tampa Two defense with underneath stuff, and go

at them the same way? Oh sure, they all do that. It's a copycat league. Chicagoat them the same way? Oh sure, they all do that. It's a copycat league. Chicago

will look at it, too, and they'll be playing it differently next year. The Cardswill look at it, too, and they'll be playing it differently next year. The Cards

attacked the Bear nickel and dime, which were vulnerable at that stage of theattacked the Bear nickel and dime, which were vulnerable at that stage of the

game. Indy? Superior personnel played a great role in this as well. game. Indy? Superior personnel played a great role in this as well. JosephJoseph

AddaiAddai was simply terrific, better than the guys trying to tackle him, no matter was simply terrific, better than the guys trying to tackle him, no matter

what defense they were in. Thanks for your compliments, Jerry, and may Iwhat defense they were in. Thanks for your compliments, Jerry, and may I

leave you with these parting words. Never underrate the matchup of personnel.leave you with these parting words. Never underrate the matchup of personnel.

It's more important than which attack plugs into which defense.It's more important than which attack plugs into which defense.

http://sportsillustrated.cnn.com/2007/writers/dr_z/05/11/mailbag/2.html

Page 38: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

Thank You!Thank You!

Any Questions?Any Questions?

Page 39: The Amazing Year: Münster (Germany), Covington (KY), Bethlehem (PA), and Huntingdon Gerald Kruse, Ph.D. Associate Professor of Computer Science and Mathematics.

BibliographyBibliographyT. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, “Introduction to Algorithms, Second Edition,” Cambridge, MA/London, England: The MIT Press/McGraw-Hill, 2003.

N. Dale, C. Weems, D. T. Joyce, “Object-Oriented Data Structures Using Java,” Boston, MA: Jones and Bartlett, 2002.

M. T. Goodrich and R. Tamassia, “Algorithm Design: Foundation, Analysis, and Internet Examples,” Wiley: New York: 2001.

D. E. Knuth, “The Art of Computer Programming, Volume 3: (Second Edition) Sorting and Searching,” Addison-Wesley-Longman: Redwood City, CA, 1998.

C. C. McGeoch, “Analyzing algorithms by simulation: Variance reduction techniques and simulation speedups,” ACM Computing Surveys, vol. 24, no. 2, pp. 195 – 212, 1992.

C. C. McGeoch, D. Precup, and P. R. Cohen, “How to find the Big-Oh of your data set (and how not to),” Advances in Intelligent Data Analysis, vol. 1280 of Lecture Notes in Computer Science, pp. 41 – 52, Springer-Verlag, 1997.

R. Sedgewick, “Algorithms in C, Parts 1-4: Fundamentals, Data Structures, Sorting, Searching, Third Edition,” Addison-Wesley: Boston, MA, 1997


Recommended