Searching data involves determining whether a value (referred to as the search key) is present in the data and, if so, finding the value's location. Two popular search algorithms are the simple linear search and the faster, but more complex, binary search. Sorting places data in order, based on one or more sort keys. A list of names could be sorted alphabetically, bank accounts could be sorted by account number, employee payroll records could be sorted by social security number and so on. This chapter introduces two simple sorting algorithms, the selection sort and the insertion sort, along with the more efficient, but more complex, merge sort. Figure 24.1 summarizes the searching and sorting algorithms discussed in this book.
Chapter |
Algorithm |
Location |
---|---|---|
Searching Algorithms: |
||
24 |
Linear Search |
Section 24.2.1 |
Binary Search |
Section 24.2.2 |
|
Recursive Linear Search |
Exercise 24.8 |
|
Recursive Binary Search |
Exercise 24.9 |
|
27 |
BinarySearch method of class Array |
Fig. 27.3 |
Contains method of classes ArrayList and Stack |
Fig. 27.4 |
|
ContainsKey method of class HashTable |
Fig. 27.7 |
|
Sorting Algorithms: |
||
24 |
Selection Sort |
Section 24.3.1 |
Insertion Sort |
Section 24.3.2 |
|
Recursive Merge Sort |
Section 24.3.3 |
|
Bubble Sort |
Exercises 24.524.6 |
|
Bucket Sort |
Exercise 24.7 |
|
Recursive Quicksort |
Exercise 24.10 |
|
24, 27 |
Sort method of classes Array and ArrayList |
Fig. 24.4, |
Searching Algorithms |
Preface
Index
Introduction to Computers, the Internet and Visual C#
Introduction to the Visual C# 2005 Express Edition IDE
Introduction to C# Applications
Introduction to Classes and Objects
Control Statements: Part 1
Control Statements: Part 2
Methods: A Deeper Look
Arrays
Classes and Objects: A Deeper Look
Object-Oriented Programming: Inheritance
Polymorphism, Interfaces & Operator Overloading
Exception Handling
Graphical User Interface Concepts: Part 1
Graphical User Interface Concepts: Part 2
Multithreading
Strings, Characters and Regular Expressions
Graphics and Multimedia
Files and Streams
Extensible Markup Language (XML)
Database, SQL and ADO.NET
ASP.NET 2.0, Web Forms and Web Controls
Web Services
Networking: Streams-Based Sockets and Datagrams
Searching and Sorting
Data Structures
Generics
Collections
Appendix A. Operator Precedence Chart
Appendix B. Number Systems
Appendix C. Using the Visual Studio 2005 Debugger
Appendix D. ASCII Character Set
Appendix E. Unicode®
Appendix F. Introduction to XHTML: Part 1
Appendix G. Introduction to XHTML: Part 2
Appendix H. HTML/XHTML Special Characters
Appendix I. HTML/XHTML Colors
Appendix J. ATM Case Study Code
Appendix K. UML 2: Additional Diagram Types
Appendix L. Simple Types
Index