Đang chuẩn bị liên kết để tải về tài liệu:
Data Structures and Algorithms in Java 4th phần 7

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

sau đó tự nhiên tham gia của cơ sở dữ liệu A và B là danh sách của tất cả ba đã ra lệnh (x, y, z) như vậy mà các cặp (x, y) là A cặp (y, z) là B. Mô tả và phân tích một thuật toán hiệu quả cho máy tính | Ifk e.getKey then we have found the entry we were looking for and the search terminates successfully returning e. If k e.getKey then we recur on the first half of the array list that is on the range of indices from low to mid - 1. If k e.getKey we recur on the range of indices from mid 1 to high. This search method is called binary search and is given in pseudo-code in Code Fragment 9.9. Operation find k on an w-entry dictionary implemented with an ordered array list S consists of calling BinarySearch S k 0 w - 1 . Code Fragment 9.9 Binary search in an ordered array list. Algorithm BinarySearch 5.k.low.high input An ordered array list 5 storing n entries and integers low and high Output An entry of 5 with key equal to k and index between low and high if such an entry exists and otherwise null if low high then return null else mid low high 2J e 4 i .gettmid if e.getKey then return e else if k e.getKeyO then return Bi iarySearch 5 A .low.mid I else return Binary Search 5. Ar mid 4- 1. high J We illustrate the binary search algorithm in Figure 9.8. Figure 9.8 Example of a binary search to perform operation find 22 in a dictio nary with integer keys implemented with an ordered array list. For simplicity we show the keys stored in the dictionary but not the whole entries. 554 Considering the running time of binary search we observe that a constant num ber of primitive operations are executed at each recursive call of method Binary Search. Hence the running time is proportional to the number of recursive calls performed. A crucial fact is that with each recursive call the number of candidate entries still to be searched in the array list S is given by the value high - low 1. Moreover the number of remaining candidates is reduced by at least one half with each recursive call. Specifically from the definition of mid the number of remain ing candidates is either mid - 1 -low 1 _low or high - mid 1 1 high - -7 Initially the number of candidate entries is n after the first .

Đã 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.