TAILIEUCHUNG - Lập Trình C# all Chap "NUMERICAL RECIPES IN C" part 7

Tham khảo tài liệu 'lập trình c# all chap "numerical recipes in c" part 7', công nghệ thông tin phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 330 Chapter 8. Sorting For small N one does better to use an algorithm whose operation count goes as a higher . poorer power of N if the constant in front is small enough. For N 20 roughly the method of straight insertion is concise and fast enough. We include it with some trepidation It is an N2 algorithm whose potential for misuse by using it for too large an N is great. The resultant waste of computer time is so awesome that we were tempted not to include any N2 routine at all. We will draw the line however at the inefficient N2 algorithm beloved of elementary computer science texts called bubble sort. If you know what bubble sort is wipe it from your mind if you don t know make a point of never finding out For N 50 roughly Shell s method only slightly more complicated to program than straight insertion is competitive with the more complicated Quicksort on many machines. This method goes as N3 2 in the worst case but is usually faster. See references 1 2 for further information on the subject of sorting and for detailed references to the literature. 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 Chapters 8-13. 2 Straight Insertion and Shell s Method Straight insertion is an N2 routine and should be used only for small N say 20. The technique is exactly the one used by experienced card players to sort their cards Pick out the second card and put it in order with respect to the first then pick out the third card and insert it into the sequence among the first two and so on until the last card has been picked out and inserted. void piksrt int n float arr Sortsan array arr into ascending numerical order by straight insertion. n is input arr is replaced on output by its sorted rearrangement. int i j float a for j 2 j n j Pick out each element in turn. a arr j i j-l while i 0 arr i a Look .

TÀI LIỆU LIÊN QUAN
10    127    1
6    150    1
7    127    1
5    125    1
6    127    1
6    115    1
6    122    1
6    174    1
7    122    1
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.