西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第四部分 查找、排列_排列 Chapter 8 SORTING(英文)

Chapter 8 SORTING 1 Introduction and Notation 2. Insertion Sort I3 Selection Sort 4. Shell Sort 5. Lower Bounds 6. Divide-and-Conquer Sorting
Chapter 8 SORTING 1. Introduction and Notation 2. Insertion Sort 3. Selection Sort 4. Shell Sort 5. Lower Bounds 6. Divide-and-Conquer Sorting

Chapter 8 SORTING(continue) 7. Mergesort for Linked Lists 8. Quicksort for Contiguous Lists 9. Heaps and Heapsort I10. Comparison of Methods 1 1. Pointers and pitfalls
Chapter 8 SORTING (continue) 8. Quicksort for Contiguous Lists 9. Heaps and Heapsort 10. Comparison of Methods 11. Pointers and Pitfalls 7. Mergesort for Linked Lists

8.1 Introduction and notation 9In an external sort there are so many records to be sorted that they must be kept in external les on disks, tapes, or the like. In an internal sort the records can all be kept internally in high-speed memory. We consider only internal sorting. We use the notation and classes set up in Chapters 6 and 7. thus we shall sort lists of records into the order determined by keys associated with the records. The declarations for a list and the names assigned to various types and operations will be the same as in previous chapters
8.1 Introduction and notation ◆In an external sort, there are so many records to be sorted that they must be kept in external les on disks, tapes, or the like. In an internal sort the records can all be kept internally in high-speed memory. We consider only internal sorting. ◆We use the notation and classes set up in Chapters 6 and 7. Thus we shall sort lists of records into the order determined by keys associated with the records. The declarations for a list and the names assigned to various types and operations will be the same as in previous chapters

C To analyze sorting algorithms, we consider both the number of comparisons of keys and the number of times entries must be moved inside a list, particularl in a contiguous list Both the worst-case and the average performance of a sorting algorithm are of interest. To find the average, we shall consider what would happen if the algorithm were run on all possible orderings of the list with n entries, there are n! such orderings altogether and take the average of the results
◆To analyze sorting algorithms, we consider both the number of comparisons of keys and the number of times entries must be moved inside a list, particularly in a contiguous list. ◆Both the worst-case and the average performance of a sorting algorithm are of interest. To find the average, we shall consider what would happen if the algorithm were run on all possible orderings of the list (with n entries, there are n! such orderings altogether) and take the average of the results

Sortable lists To write efficient sorting programs, we must access the private data members of the lists being sorted Therefore, we shall add sorting functions as methods of our basic List data structures the augmented list structure forms a new adt that we shall call a Sortable List with the following form template class sortable list: public List<Record i public: / Add prototypes for sorting methods here. private: / Add prototypes for auxiliary functions here
Sortable Lists ◆To write efficient sorting programs, we must access the private data members of the lists being sorted. Therefore, we shall add sorting functions as methods of our basic List data structures. The augmented list structure forms a new ADT that we shall call a Sortable_List, with the following form. template class Sortable_list:public List { public: // Add prototypes for sorting methods here. private: // Add prototypes for auxiliary functions here. };

Hence a Sortable list is a list with extra sorting methods The base list class can be any of the List implementations of Chapter 6. We use a template parameter class called Record to stand for entries of the sortable list C Record objects can be compared to each other or to a Key by first converting the record objects to their
◆Hence a Sortable_list is a List with extra sorting methods. ◆The base list class can be any of the List implementations of Chapter 6. ◆We use a template parameter class called Record to stand for entries of the Sortable_list. ◆Record objects can be compared to each other or to a Key by first converting the Record objects to their

Every record has an associated key of type Key. a record can be implicitly converted to the corresponding Key. the keys (hence also the records can be compared under the operations > and! Any of the Record implementations discussed in Chapter 7 can be supplied by a client, as the template parameter of a sortable list An ordered list is an abstract data type defined as a list in which each entry has a key, and such that the keys are in order; that is, if entry i comes before entry jin the list, then the key of entry i is less than or equal to the key of entry j
◆Any of the Record implementations discussed in Chapter 7 can be supplied, by a client, as the template parameter of a Sortable_list. ◆An ordered list is an abstract data type, defined as a list in which each entry has a key, and such that the keys are in order; that is, if entry i comes before entry j in the list, then the key of entry i is less than or equal to the key of entry j . Every Record has an associated key of type Key. A Record can be implicitly converted to the corresponding Key. The keys (hence also the records) can be compared under the operations ' ,' ' >= ,' ' <= ,' ' == ,' and ' !=

For ordered lists, we shall often use two new operations that have no counterparts for other lists since they use keys rather than positions to locate the entry. o One operation retrieves an entry with a specified key from the ordered list. Retrieval by key from an ordered list is exactly the same as searching. oThe second operation ordered insertion, inserts a new entry into an ordered list by using the key in the new entry to determine where in the list to insert it
•One operation retrieves an entry with a specified key from the ordered list. Retrieval by key from an ordered list is exactly the same as searching. •The second operation, ordered insertion, inserts a new entry into an ordered list by using the key in the new entry to determine where in the list to insert it. ◆For ordered lists, we shall often use two new operations that have no counterparts for other lists, since they use keys rather than positions to locate the entry

Note that ordered insertion is not uniquely specified if the list already contains an entry with the same key as the new entry since the new entry could go into more than one position cat cat cat cat COW COW COW COW do dog dog dog pIg pIg hen hen ram pIg pig Ordered ram ram ram entry Move Move Complete last entry previous insertion entry
◆Note that ordered insertion is not uniquely specified if the list already contains an entry with the same key as the new entry, since the new entry could go into more than one position

8.2 Insertion Sort Example: Init ial Insert Insen Insert Insert order second t hird fourth Fifth sixth entry entry entry entry entry sorted hen cat cat cat sorted unsorted co hen cow cow cat hen hen dog ram ram ram ram hen ewe ewe ewe ewe ewe ram he sorted dog dog dog do ram Main step, contiguous case: Before rtel Unrted s current s current Remoe current sIlt entries nu lt Sorted Sorted Vertex current Reinert current Sorted Reourtel
8.2 Insertion Sort
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第四部分 查找、排列_查找 Chapter 7 SEARCHING(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第三部分 线性表_线性表 Chapter 6 LISTS AND STRINGS(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第二部分 栈、队列、递归方法_递归 Chapter 5 RECURSION(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第二部分 栈、队列、递归方法_链式栈与队列 Chapter 4 Linked Stacks and Queues(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第二部分 栈、队列、递归方法_队列 Chapter 3 QUEUES(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第二部分 栈、队列、递归方法_栈 Chapter 2 INTRODUCTION TO STACKS(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第一部分 绪论_大规模程序开发 Chapter 1 PROGRAMMING PRINCIPLES(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第一部分 绪论_数据结构导言(中文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第一部分 绪论_C++回顾(C++编程简介,中文).ppt
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)用Dijkstra方法求最短路径.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)中缀表达式转后缀表达式.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)查找最短路径.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)四则运算计算器.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)图书馆系统.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)十进制数转化为其他进制的数.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)查找性能比较.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)列车车票查询.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)平衡二叉树.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)录像带商店.doc
- 西安建筑科技大学:《数据结构与算法》教学资源(课程设计题目任务书)前缀算术表达式转换成中缀算术表达式.doc
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第四部分 查找、排列_检索 Chapter 9 Tables And Information Retrieval(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第五部分 树结构_二叉树 Chapter 10 BINARY TREES(英文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第五部分 树结构_多叉树 Chapter 11 MULTIWAY TREES(英文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第一部分 绪论(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第二部分 线性表(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第三部分 栈、队列、递归方法(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第四部分 树与二叉树(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第五部分 图(中文).ppt
- 西安建筑科技大学:《数据结构与算法》课程教学资源(PPT电子教案)第六部分 图结构_图 Chapter 12 GRAPHS(英文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第六部分 排序(中文).ppt
- 西安建筑科技大学:《数据结构基础(选修)》课程PPT电子教案_第七部分 查找(中文).ppt
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第一部分 绪论_大规模程序开发 PROGRAMMING PRINCIPLES(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第二部分 栈、队列、递归方法_栈 INTRODUCTION TO STACKS(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第二部分 栈、队列、递归方法_队列 Queues(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第二部分 栈、队列、递归方法_递归 RECURSION(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第二部分 栈、队列、递归方法_链式栈与队列 LINKED STACKS AND QUEUES(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第三部分 线性表_线性表 LISTS(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第四部分 查找、排列_查找 Searching(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第四部分 查找、排列_排列 Sorting(英文).doc
- 西安建筑科技大学:《数据结构基础》课程课堂笔记_第四部分 查找、排列_检索 TABLES AND INFORM ATION RETRIEVAL(英文).doc