Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
và các thuật toán từ. NET Framework Class Library cũng như những người phải được phát triển Trong một thời trang theo định hướng đối tượng, tác giả trình bày mảng và ArrayLists, danh sách liên kết, bảng băm, từ điển, cây, đồ thị, phân loại và tìm kiếm cũng như các thuật toán tiên tiến, chẳng hạn như các thuật toán xác suất và lập trình năng động. | 520 e Chapter 10 Hashing if not -1 i.e. not reserved assign firstLetterValue and or lastLetterValue asg-values offirstletter word and or lastletter word return success return failure We can use this algorithm to build a hash function for the names of the nine Muses Calliope Clio Erato Euterpe Melpomene Polyhymnia Terpsichore Thalia and Urania. A simple count of the letters renders the number of times a given letter occurs as a first and last letter case sensitivity is disregarded E 6 A 3 c 2 o 2 T 2 M 1 p 1 and u 1 . According to these frequencies the words can be put in the following order Euterpe E occurs six times as the first and the last letter Calliope Erato Terpsichore Melpomene Thalia Clio Polyhymnia and Urania. Now the procedure search is applied. Figure 10.11 contains a summary of its execution in which Max 4. First the word Euterpe is tried. E is assigned the g-value of 0 whereby h Euterpe 7 which is put on the list of reserved hash values. Everything goes well until Urania is tried. All five possible g-values for u result in an already reserved hash value. The procedure backtracks to the preceding step when Polyhymnia was tried. Its current hash value is detached from the list and the g-value of 1 is tried for P which causes a failure but 2 for p gives 3 for the hash value so the algorithm can continue. Urania is tried again five times then the fifth attempt is successful. All the names have been assigned unique hash values and the search process is finished. If the g-values for each letter are A c - E o M T 0 p 2 and u 4 then h is the minimal perfect hash function for the nine Muses. The searching process in Cichelli s algorithm is exponential since it uses an exhaustive search and thus it is inapplicable to a large number of words. Also it does not guarantee that a perfect hash function can be found. For a small number of words however it usually gives good results. This program often needs to be run only once and the resulting hash function can be .