MCS-208 · Unit 9

Searching and Sorting Techniques

9 sections

Block 3 · Unit 9Searching and Sorting Techniques78 min · 9 sections

Unit 9Searching and Sorting Techniques

Follows IGNOU MCS-208, Unit 9

Searching (finding a record with a given key) and sorting (putting records in key order) are among the most frequent tasks in computing. They are closely linked: sorted data can be searched far faster. This unit compares linear and binary search, then studies the main internal sorting methods (insertion, bubble, quick, merge and heap sort) with their costs, sorting on several keys, and external sorting for files too large for main memory.

In this unit you will learn to

  • search an array with linear search and with binary search, and count their comparisons;
  • explain when each search is appropriate and where searching is used;
  • sort with insertion sort and bubble sort, and explain what a stable sort is;
  • sort with quick sort, including partitioning and its worst case;
  • sort with 2-way merge sort and heap sort, and build a heap;
  • sort records on several keys with the MSD and LSD methods;
  • describe how external sorting handles files larger than memory.

Sections in this unit

  1. 9.1Searching Basics and Linear SearchFiles, records and keys, the linear (sequential) search algorithm, its best, average and worst cases, the sentinel trick, and corrected Program 9.1.8 min
  2. 9.2Binary SearchHalving a sorted array at each step, the binary search algorithm and its stopping rule, O(log n) cost, a corrected comparison table, and descending order.10 min
  3. 9.3Applications of SearchingWhere searching is used: spell checkers, search engines, string matching and databases, and which data structures make those searches fast.9 min
  4. 9.4Insertion Sort and Bubble SortInternal sorting, stability, insertion sort and bubble sort with traces, their O(n²) costs, and why bubble sort should not swap equal keys.8 min
  5. 9.5Quick SortDivide and conquer with a pivot, the partition step with two scans, a bounds-safe corrected Program 9.3, and quick sort's average and worst cases.12 min
  6. 9.62-Way Merge SortMerging two sorted lists, bottom-up 2-way merge sort pass by pass, its O(n log n) time and O(n) extra space, and a C program for Check Your Progress 3.6 min
  7. 9.7Heap SortThe heap condition, heap insertion and bottom-up construction, heap sort step by step, and a comparison of all the sorting methods.10 min
  8. 9.8Sorting on Several KeysSorting records by more than one key, the MSD and LSD methods with a deck of cards, and why LSD needs a stable sort.7 min
  9. 9.9External SortingSorting files too large for main memory: creating sorted runs, k-way merging, replacement selection, and why the number of passes matters.8 min
↑ ↓ move↵ openTab switch type