TAILIEUCHUNG - Thuật toán Algorithms (Phần 16)

Tham khảo tài liệu 'thuật toán algorithms (phần 16)', khoa học tự nhiên, toán học phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 12. Selection and Merging Sorting programs are often used for applications in which a full sort is not necessary. Two important operations which are similar to sorting but can be done much more efficiently are selection finding the kth smallest element or finding the k smallest elements in a file and merging combining two sorted files to make one larger sorted file. Selection and merging are intimately related to sorting as we ll see and they have wide applicability in their own right. An example of selection is the process of finding the median of a set of numbers say student test scores. An example of a situation where merging might be useful is to find such a statistic for a large class where the scores are divided up into a number of individually sorted sections. Selection and merging are complementary operations in the sense that selection splits a file into two independent files and merging joins two independent files to make one file. The relationship between these operations also becomes evident if one tries to apply the divide-and-conquer paradigm to create a sorting method. The file can either be rearranged so that when two parts are sorted the whole file is sorted or broken into two parts to be sorted and then combined to make the sorted whole file. We ve already seen what happens in the first instance that s Quicksort which consists basically of a selection procedure followed by two recursive calls. Below we ll look at mergesort Quicksort s complement in that it consists basically of two recursive calls followed by a merging procedure. Both selection and merging are easier than sorting in the sense that their running time is essentially linear the programs take time proportional to N when operating on N items. But available methods are not perfect in either case the only known ways to merge in place without using extra space are too complex to be reduced to practical programs as are the only known selection methods which are guaranteed to be linear even

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.