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 then we have found the entry we were looking for and the search terminates successfully returning e. If k 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 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 . 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 Binary search in an ordered array list. Algorithm BinarySearch 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 then return e else if k then return Bi iarySearch 5 A . I else return Binary Search 5. Ar mid 4- 1. high J We illustrate the binary search algorithm in Figure . Figure 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 .