The JHAVÉ Project JHAVÉ: Java Hosted Algorithm Visualization Environment Goal: Development of a comprehensive suite of visualization-based materials for.

Slides:



Advertisements
Similar presentations
Generating GAIGS XML Scripts I Integrating Algorithm Visualization into Computer Science Education Grand Valley State University June 13-16, 2006.
Advertisements

CSCI 160 Midterm Review Rasanjalee DM.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
1 Various Methods of Populating Arrays Randomly generated integers.
An End-User Perspective On Using NatQuery Extraction From two Files T
The Web Warrior Guide to Web Design Technologies
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Automating Tasks With Macros
Java Applets A lab course by Dr. Junaid Ahmed Zubairi SUNY Fredonia.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
© The McGraw-Hill Companies, 2006 Chapter 18 Advanced graphics programming.
Program Design and Development
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
CS102--Object Oriented Programming Lecture 6: – The Arrays class – Multi-dimensional arrays Copyright © 2008 Xiaoyan Li.
1 Memory Model of A Program, Methods Overview l Closer Look at Methods l Memory Model of JVM »Method Area »Heap »Stack l Preview: Parameter Passing.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Options for User Input Options for getting information from the user –Write event-driven code Con: requires a significant amount of new code to set-up.
CST JavaScript Validating Form Data with JavaScript.
Java Unit 9: Arrays Declaring and Processing Arrays.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Abstract Data Types (ADTs) and data structures: terminology and definitions A type is a collection of values. For example, the boolean type consists of.
Server-side Scripting Powering the webs favourite services.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Topic 3 The Stack ADT.
Java: Chapter 1 Computer Systems Computer Programming II.
Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 4-1 of…
Creating Web Applications Using ASP.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
JSP Java Server Pages Softsmith Infotech.
An program As a simple example of socket programming we can implement a program that sends to a remote site As a simple example of socket.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Hash Functions and the HashMap Class A Brief Overview On Green Marble John W. Benning.
SAK 3117 Data Structures Chapter 3: STACKS. Objective To introduce: Stack concepts Stack operations Stack applications CONTENT 3.1 Introduction 3.2 Stack.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Introduction to GAIGS XML Scripting Integrating Algorithm Visualization into Computer Science Education Grand Valley State University June 13-16, 2006.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
ImageJ EE4H, M.Sc Computer Vision Dr. Mike Spann
Passing Other Objects Strings are called immutable which means that once a String object stores a value, it never changes –recall when we passed a message.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
© 2004 Goodrich, Tamassia Stacks. © 2004 Goodrich, Tamassia Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
CS 206 Introduction to Computer Science II 09 / 10 / 2009 Instructor: Michael Eckmann.
30 May Stacks (5.1) CSE 2011 Winter Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data structure An.
1 CSC 221: Computer Programming I Fall 2004 Lists, data access, and searching  ArrayList class  ArrayList methods: add, get, size, remove  example:
Generating GAIGS XML Scripts II Integrating Algorithm Visualization into Computer Science Education Grand Valley State University June 13-16, 2006.
JAVA Classes Review. Definitions Class – a description of the attributes and behavior of a set of computational objects Constructor – a method that is.
DT249-Information Systems Research Practice Programming Revision Lecture 2 Lecturer: Patrick Browne.
1 The Stack Class Final Review Fall 2005 CS 101 Aaron Bloomfield.
Applications Development
Introduction to Processing. 2 What is processing? A simple programming environment that was created to make it easier to develop visually oriented applications.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
Chapter 2 Collections. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter Objectives Define the concept and terminology related.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Introduction to Collections. Collections Collections provide a way of organizing related data in a model Different types of collections have different.
Announcements Final Exam: TBD. Static Variables and Methods static means “in class” methods and variables static variable: one per class (not one per.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
int [] scores = new int [10];
Introduction to TouchDevelop Lesson 3 – Comments & Lists Created by S. Johnson
Arrays Chap. 9 Storing Collections of Values 1. Introductory Example Problem: Teachers need to be able to compute a variety of grading statistics for.
Microsoft Foundation Classes MFC
The need for Programming Languages
A type is a collection of values
Presentation transcript:

The JHAVÉ Project JHAVÉ: Java Hosted Algorithm Visualization Environment Goal: Development of a comprehensive suite of visualization-based materials for teaching algorithms and data structures, work was partially supported by a National Science Foundation Grant, CCLI- EMD # Principal Investigators: Scott Grissom (Grand Valley State University) Myles McNally (Alma College) Thomas Naps (University of Wisconsin - Oshkosh) Website:

JHAVÉ “supports” Effective AV -- How? “Stop-and-think” questions Documentation window Pseudo-code window Input generators Audio accompaniment

A Tour of the JHAVÉ Website

JHAVÉ Organization Client-server mode of operation Generation of visualization script occurs by running algorithm on server Viewing of script handled by “dumb” rendering client Webstart facilitates deployment Users just need to access the appropriate website to run the client on their machine JHAVÉ supports a variety of scripting languages through plug-ins

The JHAVÉ Client-Server Model Algorithm Choice Input Generator Presented Script is Rendered Appropriate Input Generator Served Appropriate Script Generation Program Run Client Server Data Flows Choice Input Generator Input Vis Script

Overall GAIGS VIS Script Structure A GAIGS visualization script is defined in a show file The general script structure is: one or more snapshots followed by an optional question collection The show file could be created by hand, or (more usually) as the output of a script generating program

Example of Overall Script Structure … A Show File with Three Snapshots and a Question Collection

A Simple, but Complete, Example queue index.php?line=2 9 Color of the next queue item? red green blue A Simple Visualization Script with a Multiple Choice Question

Generating Scripts GAIGS XML scripts can be generated by programs written in any programming language However, the JHAVÉ environment is designed to directly support programs written in Java Input to programs must be specified on the command line The first command line parameter is the file name the script is to be written to Support classes are available which can be used to directly generate the required GAIGS XML

Support Classes for Script Generation ShowFile: Handles the actual writing to the script file Structure Classes: Basically one for each of the GAIGS built-in structures Linear Structures: GAIGSstack, GAIGSqueue, GAIGSlist Arrays: GAIGSarray (includes bar graphs) Trees and Graphs: GAIGStree, GAIGSgraph Text: GAIGStext Question Classes: Support various aspects of generating questions in scripts XMLfibQuestion, XMLmcQuestion, XMLmsQuestion, XMLtfQuestion

The ShowFile Class The ShowFile class is responsible for all writing to the script file Constructors: ShowFile(String fileName) file is opened, and preliminary XML written to it Key Methods: writeSnap(String title, Double titleSize, GAIGSdatastr… ds) writes to the file the XML for a snap with the title and each of the listed structures close() writes any questions and closes the file

The GAIGSstack Class I GAIGSstack functions in the usual way as a stack (with push and pop operations But also stores color and other information in a way that can remain hidden (if desired) from the client class Constructors: GAIGSstack() create a stack using defaults for location and color GAIGSstack(String n, String c, double x1, y1, x2, y2, size) create a stack with name n, color c, location, and fontSize size

The GAIGSstack Class II Key Methods: pop() push(Object o) push(Object o, String c) Key Inherited Methods (from GAIGSlist) isEmpty() peek()

import exe.*; import java.io.*; public class Example1 { static final String title = "Stack Example"; static final double titleSize = 0.08; public static void main (String [] args) throws IOException { GAIGSstack stack = new GAIGSstack(); ShowFile show = new ShowFile(args[0]); int itemsToAdd = Integer.parseInt(args[1]); for (int i = 0; i < itemsToAdd; i++) { stack.push(i); show.writeSnap(title, titleSize, stack); } show.close(); } Example Code: Using the ShowFile and GAIGSstack Classes

<!DOCTYPE show PUBLIC "-//JHAVE//DTD GAIGS SHO//EN" "gaigs_sho.dtd"> Stack Example 0 Example Output: itemsToAdd == 1 ShowFile constructor ShowFile writeSnap ShowFile close

GAIGSarray I GAIGS provides support for one and two dimensional arrays Row labels can be specified, and if the array is 2-d column labels as well If the array is a 1-d array of int, it can be shown either in the usual format or as a bar graph Here we just briefly consider the 1-d case, please consult the GAIGS API for complete details on this class

GAIGSarray II Constructor: GAIGSarray (String s, boolean bar, color c, double x1, y1, x2, y2, size) create a label with name s, color c, location, and fontSize size. Display as a bargraph if bar == true

GAIGSarray III Key Methods: set(Object o, int loc) and set(Object o, int loc, String c) set location loc to have value o, optionally with color c get(int loc) return the value at location loc setColor(int loc, String c) set the color of the item at location loc to c setName(String s) set the name of this structure to s

Activity: Bubblesort Visualization Our exercise will be to create a complete visualization for the (infamous) Bubblesort algorithm Supplied code will create the snapshot shown below:

Supplied Code import java.io.*; import java.util.Random; import exe.*; public class Sort { static final String TITLE = null;// no title static int arraySize;// # of items to sort static GAIGSarray items;// the array of items Exercise Code: Preamble

public static void main(String args[]) throws IOException { // process program parameters and create the show file object ShowFile show = new ShowFile(args[0]); arraySize = Integer.parseInt(args[1]); // define the two structures in the show snapshots items = new GAIGSarray(arraySize, true, "BubbleSort", "#999999", 0.1, 0.1, 0.9, 0.9, 0.07); // initialize the array to be sorted & show it loadArray(); show.writeSnap(TITLE, items); for (int pass = 1; pass < arraySize; pass++) for (int i = 0; i < arraySize-pass; i++) if ((Integer)(items.get(i)) > (Integer)(items.get(i+1))) swap(i, i+1); // visualization is done show.close(); } Exercise Code: Main method

// Load the array with values from 1 to the array size, then // shuffle these values so that they appear in random order. private static void loadArray () { Random rand = new Random(); for (int i = 0; i < arraySize; i++) items.set(i+1,i); for (int i = 0; i < arraySize-1; i++) swap(i, i + (Math.abs(rand.nextInt()) % (arraySize - i)) ); } // Swap two items in the array. private static void swap (int loc1, int loc2) { Object temp = items.get(loc1); items.set(items.get(loc2), loc1); items.set(temp, loc2); } Exercise Code: Support Routines

If you decide to do the activity … 1.Decide when snapshots should be taken (when do the interesting events occur?) 2.Use coloring to show the ongoing actions of the algorithm 3.Use the name of the array to produce useful messages about the status of the algorithm

Adding Interactive Questions GAIGS Scripts can be used to ask four types of questions: True / False Fill in the Blank Multiple Choice Multiple Selection A Multiple Choice Question

Question Basics All the questions in a GAIGS script are collected at the end of the XML File Each contains a unique ID number/identifier A snapshot can contain a question reference The reference is by ID number/identifier A question reference causes the question to appear when the snapshot is shown

Question Generation Support I As for GAIGS structures, there are support classes for the generation of question XML XMLtfQuestion: true / false XMLmcQuestion: multiple choice XMLmsQuestion:multiple selection XMLfibQuestion:fill in the blank Each support class allows the definition of the question text, choices, and correct answer(s)

Question Generation Support II To include a question in a snap, pass a question in ShowFile method writeSnap This method also require documentation and pseudocode urls (which may be null) writeSnap(String title, double titleSize, String doc_url, String pseudo_url, question q, GAIGSdatastr… ds) writes to the file the XML for a snap with the title, titleSize, documentation and pseudocode urls, a question and each of the listed data structures

XMLtfQuestion Constructor: XMLtfQuestion(ShowFile f, String id) The id string must be unique within a script ShowFile reference is a legacy code issue Key Methods: setQuestionText(String text) sets the text which will be displayed as the question setAnswer(boolean value) set the correct answer to value

XMLtfQuestion Example int id = 0; boolean swapIsDone = false; … XMLtfQuestion tf = new XMLtfQuestion(show, id + ""); id++; tf.setQuestionText("Will a swap be done next?"); … show.writeSnap(TITLE, null, null, tf, …); … tf.setAnswer(swapIsDone);

XMLfibQuestion Constructor: XMLfibQuestion(ShowFile f, String id) The id string must be unique within a script ShowFile reference is a legacy code issue Key Methods: setQuestionText(String text) sets the text which will be displayed as the question setAnswer(String text) set text to be one of answers to be accepted as correct

XMLfibQuestion Example int id = 0; int swapsThisPass = 0; … XMLfibQuestion fib = new XMLfibQuestion(show, id + ""); id++; fib.setQuestionText("How many swaps will be made this pass?"); … show.writeSnap(TITLE, null, null, fib, …); … fib.setAnswer(swapsThisPass + "");

Probabilistic Question Asking The support classes allow the user to define the number of questions to be asked during a session, despite how many are “added” To do this, use the alternative constructor for ShowFile: ShowFile(String fileName, int count) Exactly count questions will be asked (as long as at least that many questions have been added)

Next Activity: Bubblesort + Questions Return to your Bubblesort visualization and 1.Add a question which asks how many swaps will be made during the next pass (asked just before a pass) 2.Add a question which asks if a swap will be made (asked just before a comparison is made) 3.Use probabilistic questioning to limit the number of questions asked during a session