Visual Basic 2008 Programming: Business Applications with a Design Perspective
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Appendix A Appendix B Appendix C Home
Last change: February 13 2016 18:48:19.

 Chapter in PDF

Table of Contents

Appendix C: Sorting and Searching
Last change: February 13 2016 18:48:22.

Appendix C
Sorting and Searching

The main purpose of this appendix is to acquaint you with various sorting and searching algorithms, which should enable you to become more capable of dealing with new programming problems. The algorithms can provide you with new insight as to how a programming problem is solved. VB 2008 has built-in methods for sorting and searching. Therefore, the reason for discussing this topic is not its direct application but rather to help you build a foundation for programming skills.
Human beings prefer sorted data. Sorted data are easier to browse, and they facilitate lookup. Even computers have a better time with sorted data. More efficient search/processing algorithms can be used with sorted data. Thus, if an array is to be searched repetitively for different values, it pays to sort the array first. In batch processing (where transactions are collected into a batch and then all are processed at one time), transactions sorted in the same order as their master records (such as customer accounts) eliminate the need to search the master file back and forth to update the affected master records. In this case, sorting is a necessity for efficient processing.

You may be amazed that as simple as the goal of sorting is, virtually countless algorithms to sort data exist. This appendix discusses the following algorithms:

A careful study of the sorting algorithms allows you to appreciate the performance differences as well as helps you develop the capability to design elegant solutions to new programming problems.

A study of sorting algorithms is both important and interesting. Three decades ago, Donald E. Knuth, a well-known computer scientist asserted that nearly 20% of the computer resources at that time were used to perform sorting, according to a survey. This would suggest several alternative explanations: Sorting is important and indispensable in computer applications; sorting is not conducted efficiently; or sorting has been used unnecessarily. A careful study of sorting algorithms could help improve at least the first two situations. Sorting entails keeping all data to be sorted in an array. Then certain algorithm of comparison and rearranging (moving) data is performed until all data are in their desired positions. The following discussion assumes that the original data have already been placed in an array.

Last change: February 13 2016 18:48:23.