Algorithms: The Base of Programming Skills Eva Milková University of Hradec Králové, Rokitanského 62, 500 03 Hradec Králové, Czech Republic
[email protected]
Abstract. The area of software development has passed a rapid expansion and this trend continues so far. Each developer has to learn constantly and master new technology. But crucial role is played by the basis which developer gains at the beginning of his-her career. The essential part of studies at the faculties preparing students in the area of computer science is development of student’s ability to think algorithmically. Students must be able to create various algorithms solving given problems starting with easy ones and consecutively increase their algorithmic knowledge and shifts during studies till the level where they deeply understand much more complex algorithms. In the paper we introduce our way in which we develop algorithmic thinking of students at the beginning of their studies in the subject Algorithms and Data Structure. The described approach is framed within various digital objects dedicated to visualize the subject matter and intensify selfpreparation of students. Some of them will be introduced at the conference.
Keywords. Algorithmic thinking, multimedia study material, teaching/learning strategies.
1. Introduction The education at secondary schools and colleges in the area of informatics has changed in our country and students are led mainly to a user attitude. The user’s approach has been increasing, but the algorithmic approach is almost unknown for students. In the universities departments training students in computer-related disciplines the creation of algorithms is still taught mostly within subjects dealing with programming languages. “Concerning programming languages, today’s trend offers using pure object oriented methodologies of software development and adequate programming languages, and tools. In
spite of the fact that object oriented paradigm comes from the real world its using and application may become a difficult problem for developers whose education was based upon older structured paradigm. It seams that developers educated by structural paradigm very reluctantly enter the world of objects and make some substantial mistakes. As the structural languages and principles are used to the very tiny range of problems at present, this paradigm can be avoided and the education may be started using object oriented paradigm from the very beginning.” [1] The ability to create the basic algorithms contributes to a development of logic consideration and imagination and is an inseparable part of students’ skills studying Application Informatics and Information Management at our faculty (FIM UHK). And because the entrance examination at FIM UHK doesn’t include questions concerning the abovementioned area there are a lot of students without any algorithmic knowledge at the beginning of their studies. Therefore we devote the whole first term for increasing the algorithmic thinking of our students in the subject called Algorithms and Data Structures (ALGDS). This subject is placed before the other subjects dealing with algorithmic and programming skills. The education in ALGDS lacks all the structures and constructions connected with structured paradigm. Consequently students do not get any habits which might make the entrance into object oriented world more complicated. The entire conception of programming education at our university can be found in [2]. In the paper we describe in more detail our approach to the teaching/learning strategies in the subject Algorithms and Data Structures.
2. The subject Algorithms and Data Structures Creation of algorithms is based on the imagination of a brick-box, a nice and useful
765 th
Proceedings of the ITI 2007 29 Int. Conf. on Information Technology Interfaces, June 25-28, 2007, Cavtat, Croatia
game for children. There are only several base elements available from which children are able to create incredible buildings. Why do not use this idea also when creating algorithms? Thus when we lead our students’ first steps by creation of algorithms we explain to them that it is like building interesting objects out of just a few basic elements. In the subject Algorithms and Data Structures it means that we start our teaching with basic algorithmic structures (basic elements from the brick-box) and typical algorithmic structures (a few parts made out of these elements) written in Czech meta-language and then we let students get into the secrets of making whole algorithms (building whole constructions) written in Czech meta-language as well. By basic algorithmic structures we consider only the basic structures: sequence, selection (non-full and full selection) and iteration (while iteration and its shorter description for the case with known number of iteration-body repetitions with the step 1, i.e. for iteration). By typical algorithmic structures we consider common structures typical for the whole group of problems, as e.g. determination of the number of elements with the given property, determination of the sum and the product of the elements, searching the first and last element with the given property, determination of the maximum and minimum of all elements or of elements with the given property etc. At the lectures we explain all structures on algorithms, which use only single variables at first. We always try to use such names of variables that describe their use. Obviously, at the beginning examples of algorithms are demonstrated graphically by developing diagrams first. In the diagrams we use two types of shapes only: a rectangular for commands and a rhombus for conditions. The action of each algorithm we illustrate by a step-by-step procedure for suitable initial values. After the thorough exercise of basic algorithmic structures on problems using single variables we proceed further and explain the data structure onedimension array and later two-dimension array as well. At the lessons students apply the gained knowledge to many tasks. Each task is solved by two groups; each group includes two or three students. After some time when students prepare their solution on papers, each task is illustrated by two students (one student represents one group) at the blackboard and both solutions are
compared and discussed by all students. In this way students are led to try to find more solutions to the given task and to be able to understand the efficiency of algorithms as well.
3. Self-study and the feedback There is an important question. How can students get feedback for their solution written on papers in the Czech meta-language when studying at home and preparing for lessons? Of course, they have two books ([3], [4]) containing many solved examples, prepared for the subject Algorithms and Data Structures, available. Nevertheless, there are a lot of other tasks that we give our students to solve. We thought about the possibility to prepare for students an environment enabling them to place their solutions into the environment and be informed whether their solutions are correct or not. We offered this topic as a thesis. Last year such environment, giving the needed feedback to students, was successfully finished (see bellow the chapter Program ALGORITHMS). At our lessons we solve not only the whole tasks but we also let students complete prepared algorithms and determine values of variables similarly as you can see in the following examples. Example 1 Complete the algorithms solving the following task. In the sequence of n integers saved in the array a (in items a[1] , ..., a[n]) determine the first minimum value and then sum all integers behind the found minimum value. begin minimum := a[1]; sum := ..........; for i from 2 to n repeat begin sum := sum + ..........; if a[i] ... min then begin minimum := ..........; sum := ..........; end; end; end.
Example 2 There are n integers saved in the array a (see the table). Determine the values in the array a after finishing the following algorithm. Write them to the table.
766
begin n:=6; x:=a[1]; i := 2; while i n - 1 do begin if a[i] > x then begin a[1]:= a[i]; a[i]:= x; end; i := i + 1; end; end.
a[1] a[2] a[3] a[4] a[5] a[6] 11 8 19 7 16 17
Figure 1. Program ALGORITHMS: default setting
Students can practise such examples using a nice Web application that has been preparing for them this year (see bellow the chapter Web application ALGDS).
Around the main part for writing an algorithm there are four tool bars: Variables, Field, Output, Errors. These bars can be hidden, moved and their size can be changed (see Fig. 2).
4. Digital objects We have been looking for new tools to make our teaching more effective, interesting, entertaining and most of all, comprehensible. We also try to find approaches which make selfstudy more pleasant. Therefore we have been preparing for students multimedia study materials as such ones mentioned above. These visual materials make self-study more interesting and help students to understand the subjectmatter better. Their use within virtual study environments (see bellow the chapter Virtual study environment WebCT) enables students to get, to complete, to test and to deepen their knowledge. In the following lines let us briefly describe multimedia study material prepared for the subject Algorithms and Data Structure.
Figure 2. Program ALGORITHMS: changed setting
Moreover, program ALGORITHMS can be localized into various world-languages as we can see on Fig 3.
4.1. Program ALGORITHMS Program ALGORITHMS is developed in Borland Delphi environment within the thesis [5]. It is user friendly and provides entire graphical comfort (see Fig. 1) for users. Students can place their solutions, written in the Czech meta-language, of the given tasks in the program and the program shows them step by step how their algorithms work, if they are correct or not. The program also shows actual values of used variables in each step of the algorithm’s process.
767
Figure 3. Program ALGORITHMS: English setting
The program is not only a substantial help to students in their self-study but it helps also teachers to prepare text materials (lectures, tests etc.).
4.2. Web application ALGDS In this paper we have already mention examples in which students complete prepared algorithms and/or determine values of used variables. Within another thesis the Web application called ALGDS [6] containing such examples has been developing for self-study of our students this year. This application is divided in three kinds of such examples (see Fig. 4 – Fig. 6): • completion of omitted parts, • arrangement of mixed up parts of the given algorithms in correct order, • completion of values of the given variables. The Web application ALGDS enables students to improve their knowledge in an enjoyable way. Each students answer is analyzed and the correct answer appears if student was wrong (see Fig. 7, compare it with Fig. 4).
Figure 5. Web application ALGDS: arrangement of mixed up parts
Figure 6. Web application ALGDS: completion of values of the given variables Figure 4. Web application ALGDS: completion of omitted parts
768
Figure 9. Sorting by choice: interchange of white snowmen
Figure 7. Web application ALGDS: completion of omitted parts - result Figure 10. Sorting by choice: indication of the chosen smallest white snowman by blue colour
4.3. Visualization within animations The above mentioned program and web application are not the only multimedia study materials used within the subject Algorithms and Data Structure. It is essential material for student’s feedback but we also use several smaller digital objects as a support of lectures and students’ imagination. These small presentations are created by students through their optional projects on a script given by the teacher with regard to students needs. Let us introduce some of them and explain their use within the subject.
4.3.1. Prime Sorting Methods The three prime sorting methods help us when we explain the term algorithm at the beginning of our lectures. We provoke students to imagine the whole process (= algorithm) of sorting things by size (children by their height). Then we introduce three prime sorting methods using visualization within a nice presentation created in Macromedia Flash environment (see Fig. 8 – Fig. 10).
We consecutively describe, in verbal way, each step of these algorithms and emphasize the fact that the given task can be mostly solved by more than one algorithm. Moreover, we inform students that they will develop their knowledge during the term so that they should be able to formulate algorithms to these presented sorting methods, using Czech meta-language, at the end of the term.
4.3.2. Interchange of two values Interchange of two values often occurs as a part of algorithms. The lecturer can very easily describe this process e.g. in the following way; he/she has a pen in the left hand (first variable) and a mobile phone in the right hand (the second variable). Then he/she illustrates the interchange of these two things using table (the third variable). However students must be aware that, in contrast to real word, the value saved in a variable will stay there till it is replaced by another one. We can illustrate this fact using presentations that step by step describe the above mentioned process (see Fig. 11 – Fig. 13).
Figure 8. Sorting by choice: choice of the smallest white snowman Figure 11. Interchange of two things
769
In the paper we offer our teaching/learning strategy, as an inspiration for all who still are looking for the way of explanation this interesting and not easy topic. Our approach to description of algorithms using the Czech meta-language within the useful feedback provided by the program ALGORITHMS is more and more used also by other teachers. They are aware that today’s trend offers using pure object oriented methodologies of software development and adequate programming languages, and tools. They appreciate the fact that our teaching/learning strategy lacks all the structures and constructions connected with structured paradigm so that students do not get any habits which might make the entrance into object oriented world more complicated.
Figure 12. Interchange of two things in the computer
Figure 13. Interchange of two values
6. Acknowledgements 4.4. Virtual study environment WebCT Since 2000 we have been using the professional virtual WebCT study environment as a support for teaching and learning subjects studied at our university. All study materials prepared for lectures and lessons within the subject Algorithms and Data Structures are available for students in this virtual study environment. Thus they can find there the electronic version of the textbooks [3] and [4] together with content of lectures, setting of exercises, the program ALGORITHMS, link to the web application ALGDS. The above mentioned small presentations are placed within the particular lectures in WebCT environment to remind students the explained matter. Thanks to electronic version of the textbooks [3], [4] and algorithms placed in web application ALGDS students can easily copy any prepared algorithm to the program ALGORITHMS and then follow it there step by step, recognize the whole process, see how values have changed in variables. Thus they have opportunity to entirely understand the subject matter.
5. Conclusion There are various approaches how to teach students to create the prime algorithms, how to start with increasing basic algorithmic thinking of students and how to develop it.
This research has been partially supported by the Research plan of the Czech Ministry of Education No. MSM 184500002.
7. References [1] Slabý. A., Milková, E.: Computer Graphic as a Way of Improvement Programming Skills. In: Luzar-Stiffler V, Hljuz Dobri V editors. Proceedings of the 28th International Conference on Information Technology Interfaces; 2006 Jun 19-22; Cavtat, Croatia. Zagreb: SRCE University Computing Centre, University of Zagreb; 2006. p. 295300. [2] Kozel T., Java ve výuce programování. In: Proceedings of Informatika XVIII/2006; Czech Republic. Brno: Konvoj; 2006. p. 97102. [3] Milková E. Algoritmy – typové konstrukce a píklady. Hradec Králové: Gaudeamus; 2001. [4] Milková E. Algoritmy v píkladech. Hradec Králové: Gaudeamus; 2004. [5] Voborník P. Programovací jazyk pro podporu výuky algoritm. Hradec Králové: thesis; 2006. [6] Hotový V. Programovací jazyk pro podporu výuky algoritm. Hradec Králové: thesis; 2007 (in print).
770