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

Tham khảo tài liệu 'thuật toán algorithms (phần 11)', 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ả | ELEMENTARY SORTING METHODS 93 small index to each key before sorting or by lengthening the sort key in some other way. It is easy to take stability for granted people often react to the unpleasant effects of instability with disbelief. Actually there are few methods which achieve stability without using significant extra time or space. The following program for sorting three records is intended to illustrate the general conventions that we ll be using. In particular the main program is a peculiar way to exercise a program that is known to work only for N 3 the point is that most of the sorting programs we ll consider could be substituted for sort3 in this driver program. program threesort input output const maxN- 100- var a array of integer N i integer procedure sort3 var integer begin if a t a 2 then begin t a l a l a 2 a 2 t end if then begin t a t a l a 3 a 3 t end if then begin end end begin readin N for i l to N do read a i if then for to N do wri end. The three assignment statements following each if actually implement an exchange operation. We ll write out the code for such exchanges rather than use a procedure call because they re fundamental to many sorting programs and often fall in the inner loop. In order to concentrate on issues we ll work with algorithms that simply sort arrays of integers into numerical order. It is generally straightforward to adapt such algorithms for use in a practical application involving large keys or records. Basically sorting programs access records in one of two ways either keys are accessed for comparison or entire records are accessed 94 CHAPTER 8 to be moved. Most of the algorithms that we will study can be recast in terms of performing these two operations on arbitrary records. If the records to be sorted are large it is normally wise to do an indirect sort here the records themselves are not necessarily rearranged but rather an array of pointers or indices is rearranged so that the first pointer points to the .

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.