TAILIEUCHUNG - ALGORITHMS phần 5

Một khi một phiên bản đã được phát triển trong đó có vẻ miễn phí các hiệu ứng như vậy, điều này có thể là chương trình để sử dụng cho một tiện ích sắp xếp thư viện hoặc cho một ứng dụng phân loại nghiêm trọng. Nhưng nếu không phải là sẵn sàng đầu tư nỗ lực để chắc chắn rằng một thực hiện | 214 CHAPTER 17 branching in the tree based on the result of the comparison between the keys we branch according to the key s bits. At the first level the leading bit is used at the second level the second leading bit and so on until an external node is encountered. The code for this is virtually the same as the code for binary tree search. The only difference is that the key comparisons are replaced by calls on the bits function that we used in radix sorting. Recall from Chapter 10 that bits x k j is the j bits which appear k from the right and can be efficiently implemented in machine language by shifting right k bits then setting to 0 all but the rightmost j bits. function digitalsearch y integer x link link var b integer begin v b maxb repeat if bits v b l 0 then x xịj else x b b-l until v x .key digi tai search X end The data structures for this program are the same as those that we used for elementary binary search trees. The constant maxb is the number of bits in the keys to be sorted. The program assumes that the first bit in each key the from the right is 0 perhaps the key is the result of a call to bits with a third argument of maxb so that searching is done by setting head where head is a link to a tree header node with 0 key and a left link pointing to the search tree. Thus the initialization procedure for this program is the same as for binary tree search except that we begin with instead of We saw in Chapter 10 that equal keys are anathema in radix sorting the same is true in radix searching not in this particular algorithm but in the ones that we ll be examining later. Thus we ll assume in this chapter that all the keys to appear in the data structure are distinct if necessary a linked list could be maintained for each key value of the records whose keys have that value. As in previous chapters we ll assume that the ith letter of the alphabet is represented by the five-bit binary representation of i. That is we ll use the following sample

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.