[Translation] C # data structures and algorithms-preface & amp; Chapter 1

Source: Internet
Author: User

Preface

As a professional programmer grows, learning data structures and algorithms is crucial. Although many books introduce data structures and algorithms, most of these books are used as university teaching materials and described in Java or C ++, which is often used in Object-Oriented teaching in universities. C # is becoming a popular language. This book is suitable for C # programmers to learn the basic knowledge of data structures and algorithms.

C # Is a Language Based on. Net Framework, a rich development environment .. Net Framework class library contains a series of Data Structure-related types (also known as collection classes ). These classes include many types from Array, Arraylist, and set types to Stack and Queue classes to HashTable and SortedList. Readers can learn how to use these classes without having to understand how to implement them urgently. Before that, the instructors had to abstract the principles of the data structure (such as the stack) until such a data structure was fully constructed. Now we can teach students how to use the stack to complete some Numerical Conversion calculations, so as to quickly demonstrate the use of these classes. With these backgrounds, students can go back and learn the basics of these data structures (or algorithms) and even give their own implementations.

This book provides a practical overview of the data structures and algorithms that all programmers need to know and understand. For this reason, this book does not include formal analysis of these data structures and algorithms. Therefore, there is no single mathematical formula or Big O analysis in this article (if you do not know what this means, you can refer to any book mentioned in this book ). Instead, different data structures and algorithms are used as problem-solving tools to present them. A simple time test is used to compare the data structure and algorithm performance discussed in the book.

Prerequisites

The only preparation required by the reader in this book is a rough understanding of C. In particular, C # object-oriented programming.

Unit Organization

Chapter 2 introduces the concept of data structure as a data set, An Introduction to linear and nonlinear collection classes, and demonstrates the collection classes. This chapter also introduces the concept of generic programming, which allows programmers to write a class or method suitable for multiple data types. Generic data is an important feature added in C #, so that the generic data types (for C #2.0 and later versions) are stored in System. collections. A special class library is added to the Generic namespace. When such a library has a generic implementation of a data structure, we will study its usage. At the end of this chapter, we will discuss how to measure the data structure and algorithm performance described in this book.

Chapter 2 reviews how the Array is constructed and demonstrates some features of the Array class. The Array class encapsulates many functions related to Array Operations (such as UBound and LBound ). ArrayList is a special array that provides the ability to dynamically adjust the size.

Chapter 2 describes the basic sorting algorithms, such as sorting by bubble and inserting. Chapter 1 describes most basic Memory search algorithms, sequential search and binary search.

Chapter 2 discusses two classic data structures: Stack and queue. This chapter focuses on the practical use of these data structures in solving daily data processing problems. Chapter 2 contains the BitArray class, which can be used to efficiently represent a large number of integer values, such as test scores.

Strings are generally not discussed in books about data structures. However, chapter 7th introduces strings, including String and StringBuilder classes. In C #, many data operations are performed on strings. Readers should understand the special skills contained in these two classes. Chapter 2 describes the functions of Regular Expressions in Text Processing and style matching. Regular Expressions provide greater and more efficient processing capabilities than traditional string processing functions and methods.

Chapter 2 describes how to use the dictionary data structure. Dictionary and other different data structures based on them, and store data as key/value pairs. This chapter shows you how to create your own types based on the DictionaryBase abstract class. Chapter 10th covers hash tables and describes how to use a special dictionary-type hash method such as HashTable to save data internally.

Chapter 2 describes another classic Data Structure-linked list. The linked list in C # is not as important as the linked list in a pointer-based programming language such as C ++. But it also has its own role in C # programming. Chapter 2 introduces another typical data structure, binary tree. A special form of Binary Tree-the binary tree is the topic of this chapter. Other types of Binary Trees are arranged for discussion in chapter 15th.

Chapter 2 demonstrates how to store data in a collection class. This type of data is useful when only unique data values can be stored in a data structure. Chapter 14th includes more efficient sorting algorithms, such as popular and efficient fast sorting, which is also the basis for implementing most of the sorting processes used in the. Net Framework class library process. Chapter 3 describes three data structures-AVL Tree, red-black tree, and skip table that are not involved in the discussion of binary search trees.

Chapter 2 discusses graph and graph algorithms. Graphs are useful for displaying many different types of data, especially networks. Chapter 2 introduces the fundamental technology of Algorithm Design: Dynamic algorithms and greedy algorithms.

Thank you

I would like to thank many different types of people for helping me complete this book. First of all, thank you to the students who have listened to me for the first time about data structures and algorithms. They are (there is no pre-order): Matt Hoffman, Ken Chen, Ken Cates, Jeff Richmond, and Gordon Caffey. Clayton Ruff, my colleague at the Pulaski Institute of Technology, listened to most of my courses and provided valuable comments and criticisms. I would also like to thank my head, David Durr, and the head of the department, Bernica Tackett, who supported my writing. I would also like to thank my family for their support during my years of research and writing. Finally, I would like to give my editors Lauren Cowles and Heather Bergman many thanks to the Cambridge publishing house for answering my questions, helping to change titles and tolerating my habitual delays.

 

  1. Describes collection classes, generic classes, and timing classes.

This book discusses the development and implementation of data structures and algorithms based on the C # language. The data structure used in this book is derived from the classes contained in the System. Collections namespace in the. Net Framework class library. In this chapter, we first implement a set class (using arrays as the basis for our own implementation) to create a set concept, and then learn the set classes in. Net Framework.

An important new feature introduced in C #2.0 is generic. Using generic C # programmers can write functions of a version-or functions that are independent or exist in a class. Different data types can be accepted without the need to reload the function multiple times. C #2.0 provides a special namespace, System. Collections. Generic, which contains the implementation of the data structure in System. Collections. This chapter will introduce you to generic programming.

Finally, this chapter introduces a custom type, which will be used as a tool for measuring data structures or algorithm performance in subsequent sections. This class will replace the big O analysis, and it is not important for the big O analysis. Instead, it uses a more practical method to teach data structures and algorithms.

Set Definition

An ordered set is a data structure of the container type used to store data. It adds data to the container and removes the data from it, the data update method also provides operations to set or return values of different attributes in the set.

Collection classes can be divided into two types: linear and non-linear. A linear set is a list of elements, with the last element following the previous element. Elements in a linear set are sorted by position (first, second, third, and so on. In real life, the grocery commodity list is a good example of a linear set. In the computer world (as in reality), arrays are designed as a linear set.

Elements in a non-linear set have sequential positions. An organizational icon is an example of a non-linear set, just like a ball-hitting shelf. In computers, trees, heaps, graphs, and unordered sets are examples of non-linear sets.

A set, whether linear or non-linear, defines a series of attributes to describe them and defines the operations that can be performed on them. An example of a set attribute is the set Count attribute, which stores the number of elements in the set. The operation defined on the set is also called a method. Contains Add (Add an element to the Set), Insert (Insert an element at the specified position), Remove (Remove the specified element), Clear (Remove all elements in the set ), contains (determine whether the specified element is a member of the Set) and IndexOf (determine the position of a specified Element in the set ).

Set description

The two main types of the set include several sub-types. A linear set can be accessed directly or sequentially. A non-linear set is also divided into hierarchical or grouped ones. This section describes the preceding subtypes.

Direct access to the set

The most common example of direct access to a set is an array. An array is defined as a collection of elements of the same type, and its elements can be directly accessed through an integer index. 1.1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.