Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
A computer is a general purpose device that can be programmed to carry out a finite set of arithmetic or logical operations. Since a sequence of operations can be readily changed, the computer can solve more than one kind of problem. | Sorting and Searching Algorithms A Cookbook Thomas Niemann Preface This is a collection of algorithms for sorting and searching. Descriptions are brief and intuitive with just enough theory thrown in to make you nervous. I assume you know C and that you are familiar with concepts such as arrays and pointers. The first section introduces basic data structures and notation. The next section presents several sorting algorithms. This is followed by techniques for implementing dictionaries structures that allow efficient search insert and delete operations. The last section illustrates algorithms that sort data and implement dictionaries for very large files. Source code for each algorithm in ANSI C is available at the site listed below. Permission to reproduce this document in whole or in part is given provided the original web site listed below is referenced and no additional restrictions apply. Source code when part of a software project may be used freely without reference to the author. Thomas Niemann Portland Oregon email thomasn@jps.net home http members.xoom.com thomasn s man.htm By the same author A Guide to Lex and Yacc at http members.xoom.com thomasn y man.htm. - 2 - CONTENTS 1. INTRODUCTION_4 2. SORTING 8 2.1 Insertion Sort 8 2.2 Shell Sort 10 2.3 Quicksort 11 2.4 Comparison 14 3. DICTIONARIES 15 3.1 Hash Tables 15 3.2 Binary Search Trees 19 3.3 Red-Black Trees 21 3.4 Skip Lists 25 3.5 Comparison 26 4. VERY LARGE FILES 29 4.1 External Sorting 29 4.2 B-Trees 32 5. BIBLIOGRAPHY 36 - 3