TAILIEUCHUNG - Sorting part 3

For “randomly” ordered data, the operations count goes approximately as N , at least for N 50, however, Quicksort is generally faster. | 332 Chapter 8. Sorting For randomly ordered data the operations count goes approximately as N1-25 at least for N 60000. For N 50 however Quicksort is generally faster. The program follows void shell unsigned long n float a Sortsan array a into ascending numerical order by Shell s method diminishing increment sort . n is input a is replaced on output by its sorted rearrangement. unsigned long i j inc float v inc 1 do inc 3 inc while inc n do inc 3 for i inc 1 i n i v a i j i while a j-inc v a j a j-inc j - inc if j inc break a j v while inc 1 Determine the starting increment. Loop over the partial sorts. Outer loop of straight insertion. Inner loop of straight insertion. CITED REFERENCES AND FURTHER READING Knuth . 1973 Sorting and Searching vol. 3 of The Art ofComputer Programming Reading MA Addison-Wesley . 1 Sedgewick R. 1988 Algorithms 2nd ed. Reading MA Addison-Wesley Chapter 8. Quicksort Quicksort is on most machines on average for large N the fastest known sorting algorithm. It is a partition-exchange sorting method A partitioning element a is selected from the array. Then by pairwise exchanges of elements the original array is partitioned into two subarrays. At the end of a round of partitioning the element a is in its final place in the array. All elements in the left subarray are a while all elements in the right subarray are a. The process is then repeated on the left and right subarrays independently and so on. The partitioning process is carried out by selecting some element say the leftmost as the partitioning element a. Scan a pointer up the array until you find an element a and then scan another pointer down from the end of the array until you find an element a. These two elements are clearly out of place for the final partitioned array so exchange them. Continue this process until the pointers cross. This is the right place to insert a and that round of partitioning is done. The Sample page from NUMERICAL RECIPES IN C THE ART OF .

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.