TAILIEUCHUNG - Lecture Algorithms and data structures: Chapter 9 - Sorting Algorithms

An Abstract List (or List ADT) is linearly ordered data where the programmer explicitly defines the ordering. We will now look at our first abstract data structure: Relation - explicit linear ordering, operations, implementations of an abstract list with linked lists and arrays, memory requirements, strings as a special case, the STL vector class. | Review Selection Sort Selection Sort Algorithm Time Complexity Best case Average case Worst case Examples Sorting Algorithms There are many sorting algorithms, such as: Selection Sort Insertion Sort Bubble Sort Merge Sort Quick Sort The first three are the foundations for faster and more efficient algorithms. Sorting Sorting is a process that organizes a collection of data into either ascending or descending order. An internal sort requires that the collection of data fit entirely in the computer’s main memory. We can use an external sort when the collection of data cannot fit in the computer’s main memory all at once but must reside in secondary storage such as on a disk. We will analyze only internal sorting algorithms. Any significant amount of computer output is generally arranged in some sorted order so that it can be interpreted. Sorting also has indirect uses. An initial sort of the data can significantly enhance the performance of an algorithm. Majority of programming projects use a sort somewhere, and in many cases, the sorting cost determines the running time. A comparison-based sorting algorithm makes ordering decisions only on the basis of comparisons. Selection Sort The list is divided into two sublists, sorted and unsorted, which are divided by an imaginary wall. We find the smallest element from the unsorted sublist and swap it with the element at the beginning of the unsorted data. After each selection and swapping, the imaginary wall between the two sublists move one element ahead, increasing the number of sorted elements and decreasing the number of unsorted ones. Each time we move one element from the unsorted sublist to the sorted sublist, we say that we have completed a sort pass. A list of n elements requires n-1 passes to completely rearrange the data. 23 78 45 8 32 56 8 78 45 23 32 56 8 23 45 78 32 56 8 23 32 78 45 56 8 23 32 45 78 56 8 23 32 45 56 78 Original List After pass 1 After pass 2 After pass 3 After pass 4 After pass 5 Sorted .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.