A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen...

24
A light-weighted A light-weighted visualization tool for visualization tool for facilitating students’ facilitating students’ learning of sorting learning of sorting algorithms algorithms Sen Zhang, Hanfu Mi Sen Zhang, Hanfu Mi State University of New York State University of New York College at Oneonta College at Oneonta

Transcript of A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen...

Page 1: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

A light-weighted A light-weighted visualization tool for visualization tool for facilitating students’ facilitating students’ learning of sorting learning of sorting algorithmsalgorithms

Sen Zhang, Hanfu MiSen Zhang, Hanfu MiState University of New YorkState University of New YorkCollege at OneontaCollege at Oneonta

Page 2: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

What does a course What does a course teach?teach?

Simple facts, concepts, definitions, Simple facts, concepts, definitions, notations, etc.notations, etc.Observations & propertiesObservations & propertiesPrinciples & theoriesPrinciples & theoriesComplicated concepts & proceduresComplicated concepts & proceduresCase studiesCase studies……

Page 3: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Concepts in Computer Sciences Concepts in Computer Sciences tend to be abstract for various tend to be abstract for various reasons.reasons.Highly generalizedHighly generalized

Dynamic nature Dynamic nature Procedure orientedProcedure orientedTransformed representationTransformed representationFormally defined, in mathematical and/or Formally defined, in mathematical and/or logical languages logical languages Usually not in plain natural languagesUsually not in plain natural languagesComplicatedComplicatedDifferent platforms and magnitudesDifferent platforms and magnitudesInvisibleInvisible

Page 4: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

How to teach procedures How to teach procedures and complicated and complicated concepts?concepts?

VerbalVerbalVisualVisual

One picture is worth one thousand One picture is worth one thousand words!words!Chalk & BoardChalk & BoardPowerPointPowerPointCustomized toolsCustomized tools

Page 5: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

One picture is worth one thousand One picture is worth one thousand words!words!

Sometimes, interpreting the essential Sometimes, interpreting the essential concepts in natural languages could be concepts in natural languages could be inadequate, especially if you teach first inadequate, especially if you teach first time students.time students.Verbal is sequential, while a non-trivial Verbal is sequential, while a non-trivial concept is usually parallel, complex, concept is usually parallel, complex, and multi-faceted.and multi-faceted.One possible solution is to use One possible solution is to use visualization to complement the visualization to complement the weakness of the sole language weakness of the sole language interpretation. interpretation.

Page 6: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

A scenario where visualization is A scenario where visualization is particularly useful. particularly useful.

In a Data Structures course taught in In a Data Structures course taught in Oneonta, we explored, adopted and Oneonta, we explored, adopted and developed the visualization tools to developed the visualization tools to facilitate students’ learning of some facilitate students’ learning of some topics which could otherwise be topics which could otherwise be challenging to grasp.challenging to grasp.

Page 7: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Static vs. DynamicStatic vs. DynamicDue to the media restriction, Due to the media restriction, visualization were traditionally visualization were traditionally conveyed by static graphics.conveyed by static graphics.

instructors’ drawings on the blackboard instructors’ drawings on the blackboard or a transparencyor a transparencyfigure illustrations in traditional figure illustrations in traditional textbooks textbooks

Computer software makes dynamic Computer software makes dynamic visualization possible.visualization possible.

Different approaches.Different approaches.Java Applets Java Applets MatLabMatLabPowerPoint AnimationPowerPoint AnimationExcel through VBA Excel through VBA

Page 8: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Advantages of using Advantages of using visualization tools in visualization tools in teachingteaching

Make effective use of classroom timeMake effective use of classroom timeHelp student engaged in classHelp student engaged in classRespond to different inputs quickly Respond to different inputs quickly without delaywithout delayExtend active learning to outside of Extend active learning to outside of classroomclassroom

Page 9: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

A light-weighted A light-weighted visualization tool for visualization tool for facilitating students’ facilitating students’ learning of sorting learning of sorting algorithmsalgorithms

A tool for sorting algorithmsA tool for sorting algorithmsLight-weightedLight-weightedMore interesting work! If we have More interesting work! If we have time.time.

Page 10: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Basic definition of sorting Basic definition of sorting algorithmsalgorithms

A sorting algorithm is an algorithm A sorting algorithm is an algorithm that puts elements of a list in a that puts elements of a list in a certain order. The most used orders certain order. The most used orders are numerical order and are numerical order and lexicographical order. lexicographical order.

Efficient sorting is important to Efficient sorting is important to optimizing the use of other optimizing the use of other algorithms (such as search and algorithms (such as search and merge algorithms) that require merge algorithms) that require sorted lists to work correctly. sorted lists to work correctly.

Page 11: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Comparison based sorting Comparison based sorting algorithmsalgorithms

Bubble sortBubble sortInsert sortInsert sortSelection sortSelection sortMergesort (or Merge sort)Mergesort (or Merge sort)Quicksort (or quick sort)Quicksort (or quick sort)

Page 12: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Bubble sortBubble sort

The basic idea is to compare two The basic idea is to compare two neighboringneighboring objects, and to swap objects, and to swap them if they are in the wrong order.them if they are in the wrong order.This is probably the simplest way to This is probably the simplest way to sort an array of objects. sort an array of objects. Unfortunately, it is also the slowest Unfortunately, it is also the slowest way! way!

Page 13: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Selection sortSelection sortThe idea of selection sort is rather simple.The idea of selection sort is rather simple.We repeatedly find the next largest (or We repeatedly find the next largest (or smallest) element in the array and move it smallest) element in the array and move it to its final position in the sorted array. to its final position in the sorted array. Assume that we wish to sort the array in Assume that we wish to sort the array in increasing order, i.e. the smallest element increasing order, i.e. the smallest element at the beginning of the array and the at the beginning of the array and the largest element at the end. largest element at the end. We begin by selecting the largest element We begin by selecting the largest element and moving it to the highest index position. and moving it to the highest index position. We can do this by swapping the element at We can do this by swapping the element at the highest index and the largest element. the highest index and the largest element. We then reduce the We then reduce the effective sizeeffective size of the of the array by one element and repeat the array by one element and repeat the process on the smaller (sub)array. The process on the smaller (sub)array. The process stops when the effective size of the process stops when the effective size of the array becomes 1 (an array of 1 element is array becomes 1 (an array of 1 element is already sorted). already sorted).

Page 14: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Insertion sortInsertion sort

Insertion sort keeps making the left Insertion sort keeps making the left side of the array sorted until the side of the array sorted until the whole array is sorted. It sorts the whole array is sorted. It sorts the values seen so far and repeatedly values seen so far and repeatedly inserts unseen values in the array inserts unseen values in the array into the left sorted array. into the left sorted array. The The insertion sortinsertion sort algorithm is the algorithm is the sortsort unknowingly used by most card unknowingly used by most card players players

Page 15: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

MergesortMergesortMergesort is a recursive sorting Mergesort is a recursive sorting procedure that uses procedure that uses O(nO(n log log n)n) comparisons in the worst case. comparisons in the worst case. To merge sort an array of To merge sort an array of nn elements, we perform the following elements, we perform the following three steps in sequence: three steps in sequence: If If n<2n<2 then the array is already then the array is already sorted. Stop now. sorted. Stop now. Otherwise, Otherwise, n>1n>1, and we perform the , and we perform the following three steps in sequence: following three steps in sequence:

Sort the left half of the array. Sort the left half of the array. Sort the right half of the array. Sort the right half of the array. Merge the now-sorted left and right Merge the now-sorted left and right halves. halves.

Page 16: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

QuicksortQuicksort

Pick an element from the array (the Pick an element from the array (the pivot), partition the remaining pivot), partition the remaining elements into those greater than and elements into those greater than and less than this pivot, and less than this pivot, and recursively recursively sort the partitions. sort the partitions. Ideally, partitioning would use the Ideally, partitioning would use the medianmedian of the given values, but the of the given values, but the median can only be found by median can only be found by scanning the whole array and this scanning the whole array and this would slow the algorithm down. In would slow the algorithm down. In that case the two partitions would be that case the two partitions would be of equal size; In the simplest versions of equal size; In the simplest versions of quick sort an arbitrary element, of quick sort an arbitrary element, typically the first element is used as typically the first element is used as an estimate (guess) of the median. an estimate (guess) of the median.

Page 17: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

The tool is light-weighted. The tool is light-weighted.

It does not need extra hardware such as It does not need extra hardware such as DVD players for movies.DVD players for movies.It does not need compilers such as C++ It does not need compilers such as C++ and Javaand JavaIt does not need an expressive running It does not need an expressive running environment such as Matlabenvironment such as MatlabIt does not assume too much specialized It does not assume too much specialized knowledge in Computer Scienceknowledge in Computer ScienceAll it needs is MS Office Suite, which is All it needs is MS Office Suite, which is almost available in every campus PC, almost available in every campus PC, and the VBA script language support and the VBA script language support coming together with MSOFFICE. coming together with MSOFFICE.

Page 18: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Script languagesScript languages

Scripting languages (commonly Scripting languages (commonly called scripting programming called scripting programming languages or script languages) are languages or script languages) are computer programming languages computer programming languages created to shorten the traditional created to shorten the traditional edit-compile-link-run process. edit-compile-link-run process. The name comes from a written The name comes from a written script such as a screenplay, where script such as a screenplay, where dialog is repeated verbatim for every dialog is repeated verbatim for every performance. performance. A script is usually interpreted rather A script is usually interpreted rather than compiled.than compiled.

Page 19: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Script languagesScript languages

Script languages can be found at almost Script languages can be found at almost every level of a computer system. Besides every level of a computer system. Besides being found at the level of the operating being found at the level of the operating system, they appear in computer games, system, they appear in computer games, web applications, word processing web applications, word processing documents, network software and more. In documents, network software and more. In many ways, the terms high-level many ways, the terms high-level programming language and scripting programming language and scripting language have become entwined, and language have become entwined, and there is no clear delineation between the there is no clear delineation between the two. two. VBA script is quite sophisticated and has VBA script is quite sophisticated and has been used to write elaborate programs, been used to write elaborate programs, which are often still called scripts even which are often still called scripts even though they go well beyond automating though they go well beyond automating simple computer tasks. simple computer tasks.

Page 20: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

PowerPoint PresentationPowerPoint Presentation

PowerPointPowerPointPresentation timePresentation timeDesign timeDesign time

How to design a PowerPoint presentationHow to design a PowerPoint presentationWho do the job?Who do the job?How much time one can expect to finish a How much time one can expect to finish a quick sort algorithm animation in quick sort algorithm animation in PowerPoint?PowerPoint?Can we do better? Can we do better?

Let us elaborate the ideas by using an Let us elaborate the ideas by using an some work we have done.some work we have done.

Page 21: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

How to design PowerPoint How to design PowerPoint Animations?Animations?

Man powerMan powerSoftware, e.g. a scriptSoftware, e.g. a script

Again, you need to write a programAgain, you need to write a programWrite once, reuse many times.Write once, reuse many times.

Page 22: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Future worksFuture works

StudentsStudents’ perception about the ’ perception about the concept concept Assessment of students’ perceptionAssessment of students’ perceptionActive visualization Active visualization Visualization tools implementationVisualization tools implementation

Page 23: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Questions?Questions?

Page 24: A light-weighted visualization tool for facilitating students’ learning of sorting algorithms Sen Zhang, Hanfu Mi State University of New York College.

SUNY, College at OneontaSUNY, College at OneontaMerlot 2006Merlot 2006

Thank you very Thank you very much!much!