021 _ Delphi algorithm and Data Structure

Source: Internet
Author: User
Delphi algorithm and Data Structure

DelphiTutorial Series of books(021)DelphiAlgorithms and data structures Organize netizens (state)Email:Shuaihj@163.com

:

PDF

Appendix source code

 

 

  • Original Title: The tomes of Delphi algorithms and data structures
  • Original Publishing House: wordware Publishing
  • Author: [us] Julian Bucknall
  • Translator: Lin Qi Zhu TAO JIANG
  • Series name: Delphi technology series
  • Press: China Power Press
  • ISBN: 7508314832
  • Mounting time:
  • Published on: February 1, August 2003
  • Start: 16
  • Page number: 420
  • Version: 1-1

Introduction

Julian Bucknall, A delphi developer, provides a detailed introduction to the use of algorithms and data structures from a practical perspective. Bucknall begins with an algorithm performance discussion, covering content such as arrays, linked lists, and Binary Trees. This book emphasizes search algorithms (such as sequential and binary searches), and also focuses on sorting algorithms (including Bubble sorting, insert sorting, Hill sorting, fast sorting, and heap sorting ), in addition, related optimization technologies are provided. In addition, the author also introduced hash and hash, priority queue, state machine and regular expressions, as well as data compression technologies such as Harman and lz77.

The accompanying CD contains a fairly successful free software library ezdsl developed by the author, and the source code that can be run on different versions of Delphi and kylix, it also provides executable programs from turbopower software.

Preface

You may have just picked up this book in the bookstore, or you may have bought it and are reading it. What you need to know now is about the following questions ......

Why is it necessary to write a book about the Delphi algorithm?

Although there are many books about algorithms in the bookstore, they generally only fall within the scope of the standard computer science curriculum, and seldom study algorithms from a practical perspective. The code in these books only describes the algorithms discussed, and does not give more consideration to the specific application of related technologies in real life. From the perspective of professional programmers, many of these books are only textbooks used in the corresponding courses of universities and colleges. Some interesting content is often left for readers to practice on their own, with few answers or even none.

Of course, most of these books do not use Delphi, kylix, or Pascal. Some adopt pseudocode descriptions, some adopt C, some adopt C ++, and some adopt specific (Dujour) Languages; however, in the most famous and often referenced algorithm book, a non-existent assembly language is used (for example, the mix assembly language used in the art of computer programming, 13] -- see references ). These books do claim that they can be "applied" in C, C ++, and even Java. Is there any problem? After all, an algorithm is always an algorithm. Is it wrong to describe the algorithm in any way? Why is it hard to purchase and read a Delphi-based algorithm book?

For Delphi, I personally think it is unique in many languages and environments currently used in application development. First, similar to Visual Basic, Delphi is also an environment for rapid development of 16-bit or 32-bit Windows applications, while kylix can be used for rapid development of Linux applications. The widget can be placed above the form with just a few clicks. Some components need to be double-clicked, and then enter some code, so that the components can establish a complex and close relationship. If the event processing program is added, a seemingly good semi-finished product may be obtained.

Second, like C ++, Delphi is also close to the underlying layer and can easily access different operating system APIs. In some cases, Borland will develop units for accessing APIs and sell them together with Delphi itself: in other cases, programmers will carefully analyze the header file of C, to convert it to Delphi (see the Jedi project of http: // www, Delphi-Jedi, org ). In any case, Delphi can make full use of its advantages to properly complete tasks and manage the OS subsystem.

Delphi programmers put themselves into two camps: application programmers and system programmers. But sometimes you will find that some programmers have both. The connection between the two camps lies in that no matter which type of programmer must deal with the algorithm world, there must also be a certain understanding of the algorithm. If you have some programming experience, you may need to write binary search code. Of course, before that, you may need to sort the data in a certain order to Complete Binary Search normally. Finally, you may start to use a performance evaluation tool (Profiler), and may find bottlenecks in the tstringlist, and want to know which data structure can accomplish this task more effectively.

As a programmer, algorithms are all we work on. Beginners are always afraid of standard algorithms. I mean, before getting used to this, even the word (algorithm) itself seems very difficult to spell. However, you can consider this: a program can be defined as an algorithm for retrieving information from users and generating some output for them.

Through the efforts of computer scientists, standard algorithms have been fully developed and improved, so that you and my generation can "enjoy" these algorithms during programming. Mastering Basic Algorithms not only gives full play to your programming skills, but also prevents you from making your choice of languages. For example, if you deploy the list, this includes its advantages and disadvantages, usage, and reasons for such use, and a specific implementation that can be put into use immediately, so for the subsystem or application you are currently developing, you will have a new understanding of its design, and it will be more advantageous to use the scattered list in some places. If you don't feel like sorting, and you know how it works, you also know when to use selective sorting instead of quick sorting, therefore, you may write the relevant sorting code in the application rather than using a standard Delphi control (for example, I remember hearing a "sensational" story: Someone used a hidden tlistbox control and added a lot of strings to it, set the sorted property of the control to true, and try to use this method to make these strings orderly ).

Maybe you will say, "Well, writing algorithms is good, but why should we use Delphi or kylix ?" By the way, let's make an agreement here; otherwise, I will have to write a lot of "Delphi or kylix ". When I mention "Delphi" later, it actually refers to "Delphi or kylix ". After all, early versions of kylix are regarded as "Delphi" for Linux ". Therefore, in this book, "Delphi" refers to Windows-oriented Delphi and Linux-oriented kylix.

Let's see why Delphi is used? There are two reasons: the Object Pascal Language and the operating system. Many structures in the Delphi language are not found in other languages. Using the structure will make efficient algorithms and data structures easier and more natural to encapsulate. For example, an attribute belongs to this type. If an unexpected error occurs, the corresponding exception is also a constructor. Although in Delphi, standard algorithms can be compiled without these Delphi-specific language structures, I don't think we can feel the efficiency and charm of this language. In this book, we will specifically use the objectpascal language in Delphi in large quantities. Here I did not consider the difficulties that Java programmers can encounter when converting code. Since Delphi is marked on the cover, let's use Delphi with one mind.

Second, we should consider that in the traditional sense, the recognition of algorithms is reflected in universality, at least from the perspective of CPU and operating system. Of course, these algorithms can be applied ~ The mdows environment is optimized and can be improved for Linux. Algorithms can also be more efficient for various types of Pentium processors, various memory caches, and different virtual memory subsystems in the OS. This book will focus especially on the benefits of efficiency. However, we will not write any code in assembly language, although it should be optimized for the pipeline architecture of the current processor, however, in some cases, I still have to make it clear that there are limits on its use!

Therefore, in any case, the majority of Delphi groups really need an algorithm book, And they urgently need to be completely targeted at specific languages, operating systems, and processors, this book is born on demand. It is not translated by other books targeting other languages. Not only is this book written from the beginning, but the author of this book is "working side by side" with Delphi every day. He makes a living by writing software libraries, the complexity of developing business operation routines, classes, and tools is a breeze.

What do I need to know?

This book does not teach you how to learn Delphi programming. You need to first understand the basic knowledge of Delphi program design, such as creating a new project, writing code, completing compilation and debugging, etc. I would like to remind you that this book will not talk about controls. You must be familiar with classes, procedures and method references, non-type pointers, powerful tlist, and tstream series encapsulated as Delphi. In addition, you must have a sufficient understanding of object-oriented concepts such as encapsulation, inheritance, polymorphism, and delegation. Finally, you should not be unfamiliar or afraid of the Object Model in Delphi!

As mentioned above, many concepts described in this book are quite simple. New programmers will learn some basic content about standard algorithms and data structures from this book. In fact, analyzing the source code can help these junior programmers Master many of the skills and methods of senior programmers. The more advanced structure is left for you to study again when you need it.

Therefore, this book requires you to have some experience in writing Delphi. During programming, you may sometimes find that tlist and a set of related types are insufficient to meet your needs. Instead, you want to have other types of data structures, but you are not sure which data structures are available, or even if a structure is found, I don't know how to use it. In some cases, you may need a simple sorting routine, but the encoding language used in the reference books is C ++, to be honest, you 'd rather compile it from the beginning than convert the C ++ code. In some cases, you may also want to see an algorithm book, which will bring performance and efficiency to the same height as the description of the algorithm itself. This book is exactly what you need.

What version of Delphi is required?

Are you ready? Don't be surprised. The answer to this question is all versions. In addition to using delphi4 and later versions and kylix when discussing dynamic arrays in Chapter 2nd, some content in Chapter 12th and occasional sporadic version requirements, the code here can be compiled and run in any version of Delphi. Except for a few version-specific code I mentioned earlier, all the other code in this book has been tested in various versions of Delphi and kylix.

Therefore, you can think that all the code printed in this book applies to different versions of Delphi. Although some code lists are based on specific versions, they are all clearly stated.

Directory

Chapter 1 What is an algorithm

1.1 What is an algorithm

1.2 algorithms and platforms

1.3 debugging and Testing

Conclusion 1.4

Chapter 2 array

Array 2.1

2.2 array type in Delphi

2.3 tlist class and pointer Array

2.4 disk array

Conclusion 2.5

Chapter 3 linked list, stack, and queue

3.1 single-chain table

3.2 two-way linked list

3.3 Advantages and Disadvantages of linked list

Stack 3.4

3.5 queue

Conclusion 3.6

Chapter 4 search

4.1 comparison routine

4.2 sequential Lookup

4.3 Binary Search

Conclusion 4.4

Chapter 4 sorting

5.1 Sorting Algorithm

5.2 Basic sorting knowledge

Conclusion 5.3

Chapter 1 Random Algorithms

6.1 Random Number Generation

6.2 Other random number Distributions

6. 3 jump table

Conclusion 6.4

Chapter 3 hash and hash

7.1 Hash Functions

7.2 use the linear detection method for Conflict Resolution

7.3 other open addressing mechanisms

7.4 use chained methods to resolve conflicts

7.5 use the bucket method to resolve conflicts

7.6 scattered list on disk

Conclusion 7.7

Chapter 2 binary tree

8.1 create a binary tree

8.2 Insert and delete a tree

8.3 binary tree traversal

8.4 binary tree class implementation

8.5 Binary Search Tree

8.6 stretch tree

8.7 red/black tree

Conclusion 8.8

Chapter 1 priority queue and heap sorting

9.1 priority queue

9. 2 heap

9.3 heap sorting

9.4 extended priority queue

Conclusion 9.5

Chapter 2 state machine and Regular Expression

10.1 state machine

10.2 Regular Expression

Conclusion 10.3

Chapter 4 Data Compression

11.1 Data Representation

11.2 Data Compression

11.3-bit stream

11.4 minimum redundancy Compression

11.5 Dictionary Compression

Conclusion 11.6

Chapter 2 advanced topics

12.1 reader-writer Algorithm

12.2 producer-consumer Algorithm

12.3 find the differences between the two files

Conclusion 12.4

Postscript

References

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.