21Complexitor: An Educational Tool .... (Elvina; Oscar Karnalim) COMPLEXITOR: AN EDUCATIONAL TOOL FOR LEARNING ALGORITHM TIME COMPLEXITY IN PRACTICAL MANNER Elvina1 and Oscar Karnalim2 1, 2, Faculty of Information Technology, Maranatha Christian University Jln. Prof. Drg. Surya Sumantri No. 65, Bandung, Jawa Barat, 40164, Indonesia 1elvinazhang@gmail.com; 2oscar.karnalim@it.maranatha.edu Received: 6th December 2016/ Revised: 9th February 2017/ Accepted: 10th February 2017 Abstract - Based on the informal survey, learning algorithm time complexity in a theoretical manner can be rather difficult to understand. Therefore, this research proposed Complexitor, an educational tool for learning algorithm time complexity in a practical manner. Students could learn how to determine algorithm time complexity through the actual execution of algorithm implementation. They were only required to provide algorithm implementation (i.e. source code written on a particular programming language) and test cases to learn time complexity. After input was given, Complexitor generated execution sequence based on test cases and determine its time complexity through Pearson correlation. An algorithm time complexity with the highest correlation value toward execution sequence was assigned as its result. Based on the evaluation, it can be concluded this mechanism is quite effective for determining time complexity as long as the distribution of given input set is balanced. Keywords: Complexitor, educational tool, learning algorithm, time complexity I. INTRODUCTION The algorithm is the core topic of Computer Science (CS) field. However, since not all undergraduate CS students can understand it properly, several CS educational tools are developed. These tools target various level of algorithm understanding. It starts from technical implementation (e.g. program creation) to abstractive form (i.e. algorithmic steps). To help students in technical implementation, various educational tools are used to encourage students to implement their user-defined algorithm into source code (Guo, 2013; Laakso, Kaila, & Salakoski, 2008; Cisar, Pinter, Radosav, & Cisar, 2010). However, these tools have several unique features which distinguish them from standard Integrated Development Environments (IDEs). Guo (2013) proposed Python Tutor, an embeddable Web-based program visualization which aid ed students by providing reversible source code tracking. Students can see how their algorithm works in sequential order and verify variable contents during the process. Similar with Python Tutor, Jeliot 3 (Cisar, Pinter, Radosav, & Cisar, 2010) and Ville (Laakso, Kaila, & Salakoski, 2008) also incorporate program code tracking. However, there searches are featured with several additional features such as pop-up question and program comprehension. To avoid syntactic difficulties, several researches incorporate unique yet effective mechanisms. Radosevic, Orehovacki, and Lovrencic (2009) incorporated a ”traffic- light” system which limited the number of source code modification before compiling. Students are forced to compile their code every N modification, and they can only continue to write code if their code is successfully compiled. In such manner, the numbers of syntactic errors handled by students for each code compilation are limited. Students will never face over whelming errors caused by writing large source code at once without compiling. On the other hand, Carlisle, Wilson, Humphries, and Hadfield (2005) and Watts (2004) used flowchart-like representation for constructing algorithm. Students are not encouraged to write source code directly. Instead, they construct algorithm flowchart converted into source code. This mechanism may avoid syntactic errors which are majorly caused by permitting students to write code syntaxes directly. Areias and Mendes (2007) also applied flowchart-like representation for constructing algorithm, but they focused on teaching weak students by incorporating problem-specific questions. These questions were statically defined for each problem and utilized to guide students to solve particular problem. Even though learning algorithm implementation is important, it can only be conducted when students have already understood its algorithmic steps. Thus, several researches are focused on teaching algorithmic steps instead of technical implementation. CeeBot4 (http:// www.ceebot.com/ceebot/4/4-e.php), Karel Robot (Buck & Stucki, 2001), and Alice (Cooper, Dann, & Pausch, 2000) are several examples in this category. These researches teach students to solve problem algorithmically through interactive environments (e.g. 3D visualization and real- world object). Then,students can arrange their algorithm based on provided instructions and see how their composed algorithm researches. Meanwhile, there are researches focused on teaching how standard algorithms work instead of aiding students to construct their algorithm like VisuAlgo which incorporates animation and visualization to teach standard algorithms (Halim, 2011; Ling, 2014; Halim, Koh, Loh, & Halim, 2012). Students can learn how an algorithm works based on a particular input and see variable state for each given instructions through visualization. Similar to VisuAlgo, AP-ASD1 (Christiawan & Karnalim, 2016) also adds animation and visualization. However, it is more focused on covering course materials. It is fully-synchronized with Basic Algorithm and Data Structure course on Faculty of Information Technology in Maranatha Christian University, Indonesia. To enhance students’ understanding further, several researches do not only focus on teaching how standard algorithms work. Instead, they also focus on why a particular algorithm is better than others. Velázquez-Iturbide and Pérez-Carrasco (2009) developed GreedEx, an educational tool focused on learning greedy algorithm. Using GreedEx, students can explore how several greedy algorithms work like comparing their respective output, and determine which greedy algorithm is the best approach to solving the 22 ComTech, Vol. 8 No. 1 March 2017: 21-27 given problem. In addition, their research is also extended by incorporating Computer-Supportive Collaborative System (CSCL) and named GreedExCol (Debdi, Paredes- Velasco, & Velázquez-Iturbide, 2015). On the contrary, Jonathan, Karnalim, and Ayub (2016) developed AP-SA, an educational tool to learn algorithm strategy (i.e. brute force, greedy, back tracking, and dynamic programming). Their research incorporated case-based performance comparison so that students could determine which algorithm was the best solution to the given problem. There are five aspects that are considered on case-based performance comparison. These aspects are optimality, completeness, time complexity, execution time, and output. All of them are expected to represent algorithm characteristic for a particular problem. Nevertheless, to the researchers’ knowledge, there is no educational tool focused on teaching how to calculate time complexity. Thus, this research proposes Complexitor, an educational tool focused on teaching algorithm time complexity through algorithm implementation. This tool is named based on its function and stands for “Time Complexity Calculator”. For the initial step, Complexitor is only focused on teaching how to measure time complexity in a practical manner. Students could learn how to calculate time complexity based on actual execution of algorithm implementation. In addition, because algorithm implementation must rely on the particular programming language, Complexitor is also added with a programming language setting mechanism so students could incorporate new programming languages dynamically. II. METHODS In general, students can learn algorithm time complexity through Complexitor by the following flowchart in Figure 1. For each target of the algorithm, students must provide algorithm implementation or source code in a particular programming language, and input set. Afterward, two kinds of number sequences are generated which are execution and complexity-defined sequence. The execution sequence is generated based on the number of processed instruction or execution time through actual execution. This step requires programming language setting defined before hand since programming language instruction may be different per programming language. On the other hand, complexity-defined sequences are set by executing standard complexity functions to input size. After both sequences are generated, time complexity for the target algorithm is assigned with the most correlated complexity to execution sequence. The learning flowchart in Figure 1 is inspired from the second author’s teaching method about algorithm time complexity for weaker students. Before learning algorithm complexity in a theoretical manner, students are encouraged to see directly how algorithm time complexity is determined through actual execution. The time required for executing a particular algorithm is calculated manually based on input sets, and its complexity is determined based on its sequence similarity toward a particular complexity function. Based on the informal survey in the academic year of 2014/2015 on Faculty of Information Technology in Maranatha Christian University, Indonesia, this method is quite effective to enhance students’ further understanding of time complexity of the algorithm. To learn how to determine time complexity toward a particular algorithm, students must prepare algorithm implementation and input set. Algorithm implementation must be represented as a single file and should have a main method. It can be written in any programming language as long as its setting has been registered in Complexitor. Meanwhile, input set is seen as multiple test case files which each file should be named with input size (N), and its content should represent input details. The example of testcase files for linear search algorithm can be seen in Table 1. In this example, the researchers assume that implementation of linear search has accepted three lines as its input. The first line represents input size, the second line is input sequence, and the last line shows searched value. All testcases provided in Table 1 are intended to represent the worst case scenario like the searched value is not found. Table 1 The Sample of Test Case Files of Linear Search Algorithms Filename (N) File Content 1 1 1 -1 3 3 1 2 3 -1 5 5 1 2 3 4 5 -1 10 10 1 2 3 4 5 6 7 8 9 10 -1 Figure 1 Learning Flowchart of Complexitor 23Complexitor: An Educational Tool .... (Elvina; Oscar Karnalim) From the learning perspective, students are asked to provide algorithm implementation and input set based on the following reasons. First, most of the students miscalculate time complexity since they do not know how to implement it as a program. They naively assume that each algorithm instruction has its one-to-one correlation with program instruction. Thus, by providing algorithm implementation, students are expected to understand more about their target algorithm in detail. Second, in most cases, determining time complexity is split into three domains which are best, worst, and average cases. By providing input set, students can determine which time complexity they want to calculate. For example, if students want to calculate the worst case for linear search algorithm, they should provide input set where each searched value is not found. To design Complexitor as language-independent as possible, the researchers separate all language-dependent instructions and store them in programming language setting. Hence, Complexitor can incorporate various programming languages as long as their settings are provided. Language-dependent instructions are utilized to perform several tasks to generate execution sequence. These tasks include compiling source code, running executable file, and calculating the number of processed instructions. The first two tasks are for performing the actual execution. Both of them require students to arrange command prompt instructions for performing the tasks using a particular programming language like java and javac instruction in Java programming language. On the contrary, the latter one is to generate execution sequence based on standard counter mechanism. Students must describe how to initialize, increment, and print the counter in a particular programming language. Then, Complexitor will embed these instructions in the loaded source code, execute, and extracts its result by overriding command prompt instructions. Moreover, by default, Complexitor provides three programming language settings which cover C++, Java, and Python. These languages are selected due to their popularity in undergraduate students in Faculty of Information Technology in Maranatha Christian University, Indonesia. For a broader view of programming language setting, the setting of C++ programming language in Complexitor can be seen in Table 2. It is compiled by using GNU Compiler (g++) and its counter mechanism relies on long long int type. In addition, because compiling and running instructions require file name and path to perform their respective tasks, Complexitor provides three variables for the convenience of access. These variables are a file name with extension, file name without extension, and file path. They are named as @filenamewithextension, @ filenamewithoutextension, and @filepath respectively. Table 2 C++ Programming Language Setting Instruction Type Value Compile g++ @filepath\@filenamewithextention -o @filepath\@filenamewithoutextention Run @filepath\@filenamewithoutextention. exe Initialize counter long long int count = 0; Increment counter count++; Print counter cout<<"\n"<