The combined method of teaching Data Structure course Jafar Andishmand Computer Engineering Department, Faculty of computer science, Kabul Polytechnic University Andishmand.jafar.786@gmail.com Abstract One of the most important and core foundation stones in a computer science curriculum is The data structure course. The things make this course difficult are many complicated concepts and algorithms. In this paper, we explore the teaching method of combining theory and practice in the data structure course. The concepts such us logical structure and storage structure in the data structure are too focused to explain and the basic data organizing and accessing method. To explain the practical implementation of each data structure in the Engineering The containers in STL are announced. This will made students understand the theories more efficiently. It can help students to master each data structure and use them in different practical situations. Keywords: Data structure, logical structure Introduction Data structures are different systematic ways of organizing data and accessing data[4]. The existing data structure in a computer science curriculum is a must. In the meanwhile, it is a difficult subject for a student of the second year in the major of computer science[3]. Three aspects are the main reasons. The 1st is that there are many core concepts in this course, including the logical structure and storage structure for each kind of data structure. The 2nd one is that there are lots of complicated algorithms in this course. These algorithms are dependent on the different storage structures of the data structure. The third one is that this course requires students with strong programming ability. But this is a problem for students of the second year in local universities. Even they have a strong programming ability in languages like C/C++, they still need to understand the memory management to understand and master the data structure deeply[2][5]. So this subject always made students confused. They think this course is much more difficult than others. 2.Important theories in the data structure 2.1. Logical and storage structure From teaching understandings in these years, we have found that the important problem is to let students understand the storage mode of data structure. It will make students easy to learn complex 1|Page structure and algorithms. But there is a problem yet. It is still easy for a data structure with only one kind of logical and storage structure. But it will be hard for some data structure, which has one kind of logical structure but has more than one storage modes. 2.1.1. Logical structure The aim to use a data structure is to organize and access data. This means that you have to understand which kinds of characteristics the data structure has and which kinds of data structures could be used for different problems and situations. So the basic task is to introduce the logical relationships among data structures in the data structure course. These logical relationships can be divided into four kinds of structures: set structure, linear structure, graph structure, and tree structure. These different structures have different logical relationships. These data structures can be used to define and model different practical problems through abstracting analysis. This is the aim of data structure. 2.1.2. Storage structure On the other hand, an important thing in data structure is to introduce the knowledge that how these data structures are implemented and why they are so different. There are only two kinds of storage structures: sequence storage and chain storage. In other words, these two storage structures can be understood as dynamically allocating Non-consecutive storage space. To understand those complicated data access methods deeply this concept will help us. In the sequential or consecutive storage space allocating mode, the data storage space is allocated sequentially or consecutively at one-time. All data are stored sequentially in this consecutive space. They can be accessed by their indexes. This access method is called direct access. The time for running this method is constant which can be expressed as O(1). The data structures that use consecutive methods are: vector, array, and string. When we need to insert an element into or erase from the middle of this kind of data structure, it will lead a lot of elements moving and the running time is high O(n). In the non-sequential of non-consecutive storage space allocating mode, the data are stored in the memory dynamically and the storage spaces are not allocated consecutively. this distributed data need some help to find each other. So the link pointer turns out. The link pointer stores the address of the next node. This will help the predecessor to find its successor through the next pointer. The data stored in this sequential or non-consecutive way must be accessed sequentially and the running time is high O(n). But the inserting and erasing from the data sequence is much easier. Such data structures are linked lists and binary tree. 2.1.3. The relationship between the logical structure and storage structure Every data structure can be denoted by one of the four logical structures mentioned above. Those four logical structures can be implemented separately in consecutive storage mode and non-consecutive storage mode. In logical structure, a different data structure can be implemented in a different way to 2|Page meet the different features. This is a very important clue in the teaching process. It can clarify why there are many complicated algorithms in the data structure. For example, the stack structure can be implemented in a linked list, but it can also be implemented in vector structure. Meantime, the queue structure can be implemented in the linked list structure and it can be implemented in deque structure too. Table 1 shows the relationship between the storage structures and logical structures in the data structure. Logical structure Linear Tree Graph Set Storage structure string vector Array Linked list queue priority queue Stack heap binary tree complete binary tree graph Set map Data structure sequence sequence sequence chain Chain\ sequence Chain\ sequence Chain\ sequence Sequence Chain Sequence Sequence+chain chain chain T1. The relationship between the logical structure and storage structure[7]. In table 1, The non-linear structures, such as a tree, set and graph structures, usually can be implemented in the chain mode. The linear data structures regularly can be implemented in the sequence storage mode, excluding of the linked list. We can also implement the stack, queue, and priority queue in chain mode. The complete binary tree can be implemented in sequence mode. Since the elements in the complete binary tree are stored sequentially in the binary tree according to the layer, in this case, these elements can be stored in the sequential data structures, such as vector. 2.2. Accessing methods Dissimilar storage structures will lead to different access modes. The four accessing methods in data structure are: sequence access, direct access, hash access, index access. In the four accessing methods mentioned above except the sequence storage mode, the others are sequence-based storage mode. That means these accessing methods will access data according to their indexes and search for the data at the consecutive storage space. But there are still some differences between these accessing methods based on the indexes. The direct access method is based on the data index in the consecutive storage space. But the hash access and index access are based on the key of the data. It is a different concept. Furthermore, the index access method will be effective only when the data are ordered. It can word on the decreased or increased data. From the four accessing methods except the sequence access method, other methods will have a constant accessing time O(1) under ideal circumstances. However, in the hash and index accessing methods, the constant accessing time depends on the index multiplicity and the 3|Page solution of conflict respectively. The more multiplicities, the extended running time in the index access method is. The more conflicts in the access method, the longer running time in the hash access method is. 3. Object-oriented practice We have discussed the fundamentals and core theories in the data structure. Now we focus on the Implementation of all kinds of data structures. The object-oriented is more widely used to describe the data structure[4][6]. With an object-oriented perspective, the data structure can be abstracted as a kind of class, in which the data is defined as a private member and the operations this data can be specified as public access methods. These public methods are interfaces for the users and the users don't need to learn how the data structures are implemented. In the traditional methods of teaching, the data structures are always designed according to author's design, interest and experience and always these designs had no running environment. However these designs reveal the theory of the data structures, they are not practical and they are lack of practicality. In this case, they are just used to show the concepts and basic theory of data structure. In this case, when students finish this course, they are often confused that how to they can implement data structures in real situations and practical problems. This method separates the practical from theory. To master the data structure many researches are trying to introduce the practical implementation of data structures in practical engineering problems. These researches can help students to deeply understand data structures and master the data structure and use them more easily in practical situations[1][6]. 3.1. Container in STL The researchers considered this problem more than 10 years ago. They developed the STL (Standard Template Library base on C++ standards. The STL was designed to support the users using different order to resolve practical problems. There are several important containers in the STL: sequence container, adapter container, associate container and so on. Each data structure in the adapter container has a second template parameter, which is a kind of container and is called allocator in STL. It means the adapter container can use the various container as its storage. For example, the class queue can use a list or deque as its storage space. When the queue is implemented with deque, the storage space. When it is implemented using list, the storage space is non-consecutive and when a queue is implemented using deque the storage space is consecutive. It gives the user the choice to choose the appropriate one. There is another container in STL called iterator container. Understanding the iterator container is very important Comprehending and mastering STL. The accessing methods of containers in STL can be implemented by the class iterator. The different accessing functions are encapsulated in a single accessing mode. The process of encapsulating shows those different accessing functions in different data structures. 4. Conclusions 4|Page The experience of teachers from years of teaching and as the market shows the data structure course is, so important for students in the major of computer engineering, science, and technology. In this case, turning this course from a difficult and boring course to an interesting one is becoming an important issue. For turning this course into an interesting course rather than boring course researchers and instructors tried to find new methods of teaching and the best method they found is to combine theory and practice in the process of teaching. In this case William Ford and William Topp, wrote and book ''Data structure with C++ using STL''. They found a good way of teaching data structure. Students are so interested in the implementation of container in the STL. Through this process, they Could comprehend the theory parts, such as the storage structure and also logical structure more deeply. They can also apply these containers in the practical situations, rather than take these data structures as some boring theory. References [1] Du Zuo-yang, Research on Reform in the Teaching of Data Structure. Higher Education Forum. No.6, Dec. 2007. [2] Mo Jia-qing, The Research of Program Teaching Pattern on Data Structure, Computer Knowledge and Technology, 2007. [3] Wang Zhan-Zhong, Exploration on Teaching of Data Structure Course, Modern Computer, 2008,2. [4] William Ford, William Topp, Data Structure with C++ Using STL, Tsinghua University Press, 2003. [5] Wu Yan, Research on the Reform of Data Structure Course for Computer Specialties. Modern Computer, 2007. [6] Yin Li-ping, Huang Tong-cheng, Intensifying Data structure construction, and Training Students' Innovation Ability. Journal of Shaoyang University(Natural Science Edition), Vol 4, No. 4, Dec. 2007. [7] William Ford, William Topp, Data structure with C++ using STL 5|Page