September 12 1 An Algorithm for: Explaining Algorithms Tomasz Müldner.

Slides:



Advertisements
Similar presentations
1 CASUS Authoring System 07/2010 E-Learning & E-Teaching Welcome to the CASUS Authoring System!
Advertisements

TWO STEP EQUATIONS 1. SOLVE FOR X 2. DO THE ADDITION STEP FIRST
Ernst Oberortner Vienna University of Technology.
1 Verification by Model Checking. 2 Part 1 : Motivation.
Art Foundations Exam 1.What are the Elements of Art? List & write a COMPLETE definition; you may supplement your written definition with Illustrations.
Slide 1 Insert your own content. Slide 2 Insert your own content.
Design Patterns.
© 2005 by Prentice Hall Appendix 3 Object-Oriented Analysis and Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George.
By D. Fisher Geometric Transformations. Reflection, Rotation, or Translation 1.
Growing Every Child! The following slides are examples of questions your child will use in the classroom throughout the year. The questions progress from.
Debugging in End- User Software Engineering summarized by Andrew Ko Toward Sharing Reasoning to Improve Fault Localization in Spreadsheets Joey Lawrance,
Source of slides: Introduction to Automata Theory, Languages and Computation.
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
Using Text Effectively in the Biology Classroom
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
MULTIPLYING MONOMIALS TIMES POLYNOMIALS (DISTRIBUTIVE PROPERTY)
ADDING INTEGERS 1. POS. + POS. = POS. 2. NEG. + NEG. = NEG. 3. POS. + NEG. OR NEG. + POS. SUBTRACT TAKE SIGN OF BIGGER ABSOLUTE VALUE.
MULTIPLICATION EQUATIONS 1. SOLVE FOR X 3. WHAT EVER YOU DO TO ONE SIDE YOU HAVE TO DO TO THE OTHER 2. DIVIDE BY THE NUMBER IN FRONT OF THE VARIABLE.
SUBTRACTING INTEGERS 1. CHANGE THE SUBTRACTION SIGN TO ADDITION
MULT. INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Visual Model-based Software Development EUD-Net Workshop, Pisa, Italy September 23 rd, 2002 University of Paderborn Gregor Engels, Stefan Sauer University.
Methoden …\uml.ppt Folie:1 Rainer Kröning Unified Modeling Language.
Mathematics and Special Education Leadership Protocols Protocol 2: Essential Understandings About Students with Disabilities Developed in collaboration.
Linear Lists – Array Representation
Topic 14 Searching and Simple Sorts "There's nothing in your head the sorting hat can't see. So try me on and I will tell you where you ought to be." -The.
ABC Technology Project
O X Click on Number next to person for a question.
© S Haughton more than 3?
TU e technische universiteit eindhoven / department of mathematics and computer science 1 Empirical Evaluation of Learning Styles Adaptation Language Natalia.
5.9 + = 10 a)3.6 b)4.1 c)5.3 Question 1: Good Answer!! Well Done!! = 10 Question 1:
Name Convolutional codes Tomashevich Victor. Name- 2 - Introduction Convolutional codes map information to code bits sequentially by convolving a sequence.
1 Directed Depth First Search Adjacency Lists A: F G B: A H C: A D D: C F E: C D G F: E: G: : H: B: I: H: F A B C G D E H I.
Energy & Green Urbanism Markku Lappalainen Aalto University.
Models 1/22 Broadbent Geoffrey (1973). Design in Architecture: architecture and the human sciences, John Wiley and Sons, London E = mc 2.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 4 Slide 1 Software processes 2.
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving An Introduction Stewart Blakeway
Past Tense Probe. Past Tense Probe Past Tense Probe – Practice 1.
Video Audio Shot 1 Shot: Long Shot Girl starts floating in the air as she is yelling at her teacher. The teacher is heard whimpering at the sight and sound.
Properties of Exponents
Addition 1’s to 20.
25 seconds left…...
CSTA K-12 Computer Science Standards (rev 2011)
Test B, 100 Subtraction Facts
11 = This is the fact family. You say: 8+3=11 and 3+8=11
Week 1.
We will resume in: 25 Minutes.
Singapore Math Learning approach developed to instill mathematical thinking at every stage. Through this, students can solve formidable problems early.
1 Ke – Kitchen Elements Newport Ave. – Lot 13 Bethesda, MD.
O X Click on Number next to person for a question.
Learning Outcomes Participants will be able to analyze assessments
How Cells Obtain Energy from Food
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14: More About Classes.
Copyright © 2012 Pearson Education, Inc. Chapter 14: More About Classes.
Insertion Sort Introduction to Algorithms Insertion Sort CSE 680 Prof. Roger Crawfis.
From Model-based to Model-driven Design of User Interfaces.
Improving System Safety through Agent-Supported User/System Interfaces: Effects of Operator Behavior Model Charles SANTONI & Jean-Marc MERCANTINI (LSIS)
Discrete Structures Chapter 6: Set Theory
Foundations of Data Structures Practical Session #11 Sort properties, Quicksort algorithm.
Program Slicing – Based Techniques
EDMEDIA, June 24, A New Approach to Learning Algorithms Tomasz Müldner*, Elhadi Shakshuki and Joe Merrill Jodrey School of Computer Science, Acadia.
June 27, 2002 HornstrupCentret1 Using Compile-time Techniques to Generate and Visualize Invariants for Algorithm Explanation Thursday, 27 June :00-13:30.
Building Interactivity into MultiMedia: Theory into Practice by Lauren Cifuentes.
Object-Oriented Analysis and Design An Introduction.
Chapter 0: Introduction
Benefits of Thinking Maps
Presentation transcript:

September 12 1 An Algorithm for: Explaining Algorithms Tomasz Müldner

September 12 2 Vision = what is where by looking Visualization = the power or process of forming a mental image of vision of something not actually present to the sight You have 10s to find this image

3 Dijkstra feared… “…permanent mental damage for most students exposed to program visualization software …”

September 12 4 Contents Preface Introduction to Algorithm Visualization, AV Examples of AV Algorithm Explanation, AE Examples of AE Conclusions & Future Work

September 12 5 Preface Under Construction Early version Invitation to collaborate

September 12 6 Al-Khorezmi -> Algorithm The ninth century: the chief mathematician in the academy of sciences in Baghdad

September 12 7 Introduction to AV AV uses multimedia: –Graphics –Animation –Auralization to show abstractions of data

September 12 8 Examples of AV Multiple Sorting Duke More AIA

September 12 9 Typical Approach in AV take the description of the algorithm graphically represent data in the code using bars, points, etc. use animation to represent the flow of control show the animated algorithm and hope that the learner will now understand the algorithm

September Problems with AV Graphical language versus text Low level of abstraction (code stepping) Emphasis on meta-tools Students perform best if they are asked to develop visualizations no attempt to visualize or even suggest essential properties, such as invariants Very few attempts to visualize recursive algorithms

September Introduction to AE systematic procedure to explain algorithms: an algorithm for explaining algorithms Based on findings from Cognitive Psychology, Constructivism Theory, Software Engineering visual representation is used to help reason about the textual representation Use multiple abstraction levels to focus on selected issues Designed by experts

September Goals of AE Understanding of both, what the algorithm is doing and how it works Ability to justify the algorithm correctness (why the algorithm works) Ability to code the algorithm in any programming language Understanding of time complexity of the algorithm

September Requirements for AE The algorithm is presented at several levels of abstraction Each level of abstraction is represented by the abstract data model and pseudocode The design supports active learning The design helps to understand time complexity

September Levels of Abstraction public static void selection(List aList) { for (int i = 0; i < aList.size(); ++i) swap(smallest(i, aList), i, aList); } Primitive operations can be: Explained at different abstraction level inlined

September AE Catalogue Entries Multi-leveled Abstract Algorithm Model Example of an abstract implementation of the Abstract Algorithm Model Tools that can be used to help to predict the algorithm complexity Questions for students

September MAK Uses multimedia: –Graphics –Animation –Auralization to show abstractions of data Interacts with the student; e.g. by providing post-tests Uses a student model for adaptive behavior

September MAK Selection Sort Insertion Sort Quick Sort

September Selection Sort: Abstract Data Model Sequences of elements of type T, denoted by Seq with a linear order defined in one of three ways: type T supports the function int compare(const T x) type T supports the “<” relation there is a global function int comparator(const T x, const T y)

September Selection Sort: Top level of Abstraction Abstract Data Model Type T also supports the function swap(T el1, T el2) The following operations on Seq are available: a sequence t can be divided into prefix and suffix the prefix can be incremented (which will decrement the suffix ) first(suffix) T smallest(seq t, Comparator comp)

September Selection Sort: Top level of Abstraction Pseudocode void selection(Seq t, Comparator comp) { for(prefix = NULL; prefix != t; increment prefix by one element) swap( smallest(suffix, comp), first(suffix) ); }

September void selection(Seq t, Comparator comp) { for(prefix = NULL; prefix != t; increment prefix by one element) swap( smallest(suffix, comp), first(suffix) ); } Visualization List two invariants

September List two invariants void selection(Seq t, Comparator comp) { for(prefix = NULL; prefix != t; increment prefix by one element) swap( smallest(suffix, comp), first(suffix) ); }

September Selection Sort: Low level of Abstraction Pseudocode T smallest(Seq t, Comparator comp) { smallest = first element of t; for(traverse t forward) if(smallest & current are out of order) smallest = current; }

September T smallest(Seq t, Comparator comp) { smallest = first element of t; for(traverse t forward) if(smallest & current out of order) smallest = current; } Visualization

September Abstract Implementation The Abstract Iterator Implementation Model assumes There is an Iterator type, where iterations are performed over a half-closed interval [a, b) Iterator type supports the following operations: –two iterators can be compared for equality and inequality –there are operations to provide various kinds of traversals; for example forward and backward –an iterator can be dereferenced to access the object it points to

September Abstract Implementation The Abstract Iterator Implementation Model assumes (Cont.): The domain Seq supports Seq ::Iterator The following two operations are defined on sequences: –Iterator t.begin() –Iterator t.end()

September Selection Sort: Abstract Implementation Pseudocode void selection(Seq t, Comparator comp) { Seq ::Iterator eop; // end of prefix for(eop = t.begin(); eop != t.end(); ++eop) swap(smallest(eop, t.end(), comp), eop); } T smallest(Seq t, Comparator comp) { Iterator small = t.begin(); Iterator current; for(current = t.begin(); current != t.end(); ++current) if(value of current < value of small) small = current; return value of small; }

September void selection(T *x, T* const end, int comparator(const T, const T)) { T* eop; for(eop = x; eop != end; ++eop) swap( smallest(eop, end, comparator), eop ); } T *smallest(T * const first, T * const last, int comparator(const T, const T) ) { T *small = first; T *current; for( current = first; current != last; ++ current ) if(comparator(* current, *small) < 0) small = current ; return s; } void selection(Seq t, Comparator comp) { Seq ::Iterator eop; // end of prefix for(eop = t.begin(); eop != t.end(); ++eop) swap(smallest(eop, t.end(), comp), eop); } T smallest(Seq t, Comparator comp) { Iterator small = t.begin(); Iterator current; for(current = t.begin(); current != t.end(); ++current) if(value of current < value of small) small = current; return value of small; } C implementation

September typedef struct { int a; int b; } T; #define SIZE(x) (sizeof(x)/sizeof(T)) T x[ ] = { {1, 2}, {3, 7}, {2, 4}, {11, 22} }; #define S SIZE(x) int comparator1(const T x, const T y) { if(x.a == y.a) return 0; if(x.a < y.a) return -1; return 1; } int comparator2(const T x, const T y) { if(x.a == y.a) if(x.b = y.b) return 0; else if(x.b < y.b) return -1; else return 1; if(x.a < y.a) return -1; return 1; } int main() { printf("original sequence\n"); show(x, S); selection(x, x+S, comparator1); printf("sequence after first sort\n"); show(x, S); selection(x, x+S, comparator2); printf("sequence after second sort\n"); show(x, S); }

September template void selection(Iterator first, Iterator last, Predicate compare) { Iterator eop; for(eop = first; eop != last; ++eop) swap(*min_element(eop, last, compare), *eop); } void selection(Seq t, Comparator comp) { Seq ::Iterator eop; // end of prefix for(eop = t.begin(); eop != t.end(); ++eop) swap(smallest(eop, t.end(), comp), eop); } T smallest(Seq t, Comparator comp) { Iterator small = t.begin(); Iterator current; for(current = t.begin(); current != t.end(); ++current) if(value of current < value of small) small = current; return value of small; } C++ implementation

September public static void selection(List aList, Comparator aComparator) { for (int i = 0; i < aList.size(); i++) swap(smallest(i, aList, aComparator), i, aList); } private static int smallest(int from, List aList, Comparator aComp) { int minPos = from; int count = from; for (ListIterator i = aList.listIterator(from); i.hasNext(); ++count) if (aComp.compare(i.next(), aList.get(minPos)) < 0) minPos = count; return minPos; } void selection(Seq t, Comparator comp) { Seq ::Iterator eop; // end of prefix for(eop = t.begin(); eop != t.end(); ++eop) swap(smallest(eop, t.end(), comp), eop); } T smallest(Seq t, Comparator comp) { Iterator small = t.begin(); Iterator current; for(current = t.begin(); current != t.end(); ++current) if(value of current < value of small) small = current; return value of small; } Java implementation

September Algorithm Complexity Three kinds of tools: to experiment with various data sizes and plot a function that approximates the time spent on execution with this data. a visualization that helps to carry out time analysis of the algorithm questions regarding the time complexity

September Post Test 1.What is the number of comparisons and swaps performed when selection sort is executed for: 1.sorted sequence 2.sequence sorted in reverse 2.What is the time complexity of the function isSorted(t), which checks if t is a sorted sequence? 3.Hand-execute the algorithm for a sample set of input data of size 4. 4.Hand-execute the next step of the algorithm for the specified state 5.What’s the last step of the algorithm? 6.There are two invariants of this algorithm; which one is essential for the correctness of swap(smallest(), eop), and why. 7.“do it yourself “

September Quick Sort Pseudocode void quick(Seq t, Comparator comp) { if( size(t) <= 1) return; pivot = choosePivot(t); divide(pivot, t, t1, t2, t3, comp); quick(t1, comp); quick(t3, comp); concatenate(t, t1, t2, t3); }

September 12 35

September 12 36

September 12 37

September Future Work evaluation (eye movement?) student model different visualizations more complex algorithms Algorithmic design patterns generic approach MAK