Online Collection of Algorithms
Total Page:16
File Type:pdf, Size:1020Kb
JOHANNES KEPLER UNIVERSITAT¨ LINZ JKU Faculty of Engineering and Natural Sciences Online Collection of Algorithms Master’s Thesis submitted in partial fulfillment of the requirements for the academic degree Diplom-Ingenieur in the Master’s Program Computer Science Submitted by Wolfgang K¨ullinger,BSc. At the Institut f¨urSystemsoftware Advisor a.Univ.-Prof. Dipl.-Ing. Dr. G¨untherBlaschek Linz, November 2015 Abstract This thesis presents an interactive web platform, that provides an online knowledge base for common algorithms. The main target are algorithms that are important for ongoing computer scientists. The platform offers the possibility to try algorithms immediately. Every execu- tion step can be analyzed. The changes in the memory are visualized. Run-time statistics are collected and can be used to compare similar algorithms. New algorithms can be added using a registered user account. An author can use a graphical programming language to define algorithms. Any kind of information can be attached. Using comments and annotations, an algorithm can be explained in more detail. In particular students could benefit from the visual presentation of important algorithms. A web browser and an internet connection is needed in order to use the platform. There is no need to install any tools on the computer. It is not required to register for the basic functionality. This thesis gives insights about the program's internals. Some implementation details are explained extensively. The basic architecture is discussed and sketched schematically. It is a guide through the possibilities of the web application. All areas are explained using examples and illustrations. It also serves as documentation. A detailed guideline describes the necessary steps in order to install the system on a web server. All the possible configuration settings are explained in detail. ii Kurzfassung Diese Abhandlung pr¨asentiert eine interaktive Web-Plattform, die eine Sammlung von ublichen¨ Algorithmen bereith¨alt. Haupts¨achlich werden jene Algorithmen ge- sammelt, die fur¨ Informatik-Studierende relevant sind. Die Plattform bietet die M¨oglichkeit, Algorithmen sofort zu probieren. Jeder Ausfuhrungsschritt¨ kann dabei analysiert werden. Anderungen¨ im Speicher werden visualisiert. Eine Laufzeit-Statistik wird aufbereitet und kann dafur¨ verwendet werden, ¨ahnliche Algorithmen zu vergleichen. Mittels eines registrierten Kontos k¨onnen neue Algorithmen hinzugefugt¨ werden. Es kann auf eine grafische Programmiersprache zuruck¨ gegriffen werden, um einen Algorithmus zu definieren. Hintergrundinformationen k¨onnen hinzugefugt¨ werden. Kommentare und Anmerkungen k¨onnen dazu verwendet werden, einen Algorith- mus noch weiter auszufuhren.¨ Vor allem Studierende k¨onnten von der visuellen Pr¨asentation wichtiger Algorithmen profitieren. Um die Plattform verwenden zu k¨onnen, werden ein Web-Browser und eine Internetverbindung ben¨otigt. Es mussen¨ keine zus¨atzlichen Werkzeuge installiert werden. Auch eine Anmeldung ist nicht n¨otig, um die Grundfunktionalit¨at nutzen zu k¨onnen. Die Abhandlung gew¨ahrt Einblicke in den Aufbau des Programms. Einige Imple- mentierungs-Details werden ausfuhrlich¨ erkl¨art und die grunds¨atzliche Architektur wird diskutiert und schematisch skizziert. Alle M¨oglichkeiten und Bereiche der Web-Anwendung werden exemplarisch beschrieben. Sie dient ebenso als Dokumentation. Genaue Anweisungen beschreiben die n¨o- tigen Schritte, um das Programm auf einem Web-Server zu installieren. Alle Kon- figurationsm¨oglichkeiten werden er¨ortert. iii Contents 1 Introduction 1 1.1 Motivation . 1 1.1.1 Assignment . 1 1.1.2 Target groups . 2 1.2 Results . 3 1.2.1 Outline . 3 1.2.2 Supported algorithms . 4 1.3 Overview . 5 2 Foundations 6 2.1 Related work . 6 2.2 Environment . 9 2.2.1 FLOSS principles . 9 2.2.2 Web application . 9 2.3 Diagrams . 10 3 Language 13 3.1 Design . 13 3.2 Data types . 13 3.2.1 Type conversion . 14 3.2.2 Variables . 14 3.3 Building block elements . 15 3.3.1 Annotation building blocks . 16 3.3.2 Operation building blocks . 17 3.3.3 Structure building blocks . 20 3.3.4 Value building blocks . 22 3.4 Example . 22 4 Usage 25 4.1 User interface . 25 4.2 Algorithm user interface . 26 4.2.1 View perspective . 27 4.2.2 Edit perspective . 29 iv Contents 4.3 Management user interface . 32 4.3.1 Algorithm management . 32 4.3.2 User management . 33 5 Architecture 35 5.1 Rationale . 35 5.2 Server & Client . 36 5.2.1 Communication . 36 5.2.2 Tasks . 37 5.3 Database . 38 6 Implementation 40 6.1 Data types . 40 6.1.1 Variables . 41 6.2 Tree structure . 41 6.2.1 Building blocks and Nodes . 42 6.2.2 Parsing . 43 6.3 Tree traversal . 43 6.3.1 Execution . 44 6.4 Storage . 46 6.5 Used technology . 48 7 Configuration 49 7.1 Installation . 49 7.1.1 Prerequisites . 49 7.1.2 File system preparations . 50 7.1.3 Database preparations . 50 7.2 Settings . 51 7.2.1 Optional settings . 51 7.2.2 Language settings . 53 7.2.3 Section settings . 54 8 Technical data 55 8.1 Test environment . 55 8.1.1 System configuration . 56 8.1.2 Test algorithm . 57 8.2 Benchmarks . 58 9 Review 60 Creation . 60 Acknowledgements . 61 v Contents List of Figures 63 List of Listings 64 Bibliography 65 A Benchmark data 67 vi 1 Introduction This chapter gives insights about the idea that led to the development of the software system. Target groups are identified and the expected outcome is defined. It also serves as a guide through the rest of the thesis. 1.1 Motivation Every computer scientist gets to know a lot of common algorithms during educa- tion. These are not always easy to understand. Simple diagrams can help. The static content of diagrams is not always able to make the flow of data understand- able. Yet the visualization of this flow is important. The idea is to provide an interactive system to simplify the learning process. 1.1.1 Assignment The idea of an \Online Collection of Algorithms" is a web-based system used for the management of and interaction with algorithms. Algorithms should be prepared by the community. On the one hand it should serve as a centralized knowledge base that contains information about basic algorithms. On the other hand it should be easy to try this knowledge immediately. Teachers should be able to describe common algorithms in a visual way. These algorithms should be executable step by step. The student should be able to follow the stages of the execution in every detail. The definition and description of new algorithms should work without any fur- ther tools. When looking at an algorithm, the intention of its author should be easily understandable. The playback functionality should be simple and clearly 1 Introduction arranged. Following the control and data flow should be intuitive and predictable. The values of community should be promoted through the possibility to share content among other users. One explicit requirement is the possibility to compare algorithms. This requires the introduction of algorithm statistics and metrics. Pseudo-code and annotations should be available in order to support the intentions of authors. Textual as well as graphical representation of an algorithm should be supported. Cross-referencing between algorithms should be possible. General background information as well as external references should be attachable. Users should interact with the system using web browsers. This makes the system independent of the users' operating systems. The aim is to create a system that can be run on most common server technology. An amount of predefined algorithms should demonstrate the functionality and the abilities of the system. These should preferably be algorithms that are impor- tant for computer science students. 1.1.2 Target groups The major target groups can be found in an academic context. The knowledge about fundamental algorithms is part of every computer scientist's education. Therefore the aim of this system is to support teachers on defining algorithms that can be presented in class. Students should be supported to understand algo- rithms more easily. Teachers are the first group that has contact with the system. Teachers for com- puter science do not necessarily need to have programming experience. Therefore the algorithm definition process has to be designed in a way that no program- ming skills are required. Computer scientists with experience concerning software development should also be able to define algorithms. This raises the idea of pro- viding a graphical system that is closely related to the usual textual way of writing algorithms. Students are the group that mainly uses algorithms that are already defined. The system should be aware of students that have little or no programming expe- rience. The relationship of the memory contents and the algorithm must be clearly 2 Introduction visible. If an instruction in the algorithm manipulates the contents of a memory cell, this must be obvious and easy to follow. The computation costs of selected operations are important for being able to compare algorithms. One basic use case can be concluded involving both major target groups. In order to prepare a lesson, a teacher defines an algorithm. Comments can be prepared and basic information attached. The algorithm can be either demonstrated to the students or students can play with the algorithm individually. Both alternatives can be directly applied in class. 1.2 Results The program that was developed in the course of this thesis is named \kartuli- mardikas". This is the Estonian name of the \Colorado potato beetle". The name serves as working title during development. The nominal association with a software bug is intended. It characterizes software products in general, especially those in development. It might also serve as reminder for the future authors of algorithms who use this system.