1. External and internal arching
大学生活规划书>谭嗣同传ANSWER:
The arching problem falls naturally into two ca. If there are many records, perhaps each one quite large, then it will be necessary to store the records in files on disk or tape, external to the computer memory. This ca is called external arching. In the other ca, the records to be arched are stored entirely within the computer memory. This ca is called internal arching. We will consider only internal arching in this term.
We shall be concerned only with contiguous list in this chapter. Hence we shall always be arching in a contiguous list that we generally call list. What we have called records will be C structures, and they will be the entries in the list LIST. The C type that the records have we shall name as ListEntry, as we have for lists. One of the fields of each list entry will be denoted key and have a type called KeyType.
和胃Examples: float, int, char
2. Binary arch
ANSWER:
Sequential arch is easy to write and efficient for short lists, but a disaster of long ones. One of the best is to compare the target key with the one in the center of the list and then restrict our attention to only the first or the cond half of the list, depending on whether the target key comes before or after the central one.
The method we are discussing is called binary arch. This approach requires that the entries in the list be of a scalar of other type that can be regarded as having an order and that the list already be completely in order.
Since binary arch requires jumping back and forth from one end of the list to the middle, it requires an implementation of the list in which the random access is rapid, as it is within an array, but not within a simply linked list. Hence we shall study binary arch only for the array implementation.
Definition:
An ordered list in which each entry contains a key, such that the keys are in order. That is, if entry i comes before entry j in the list, then the key of entry i is less than or equal to the key of entry j.
人鼠大战>寄售合同Algorithm development:
Our binary arch algorithm will u two indices, top and bottom, to enclo the part of the list in which we are looking for the target key.
The target key, provided it is prent in the list, will be found between the indices bottom and top, inclusive. We establish the initial correctness of this statement by tting bottom to 0 and top unt-1, unt is the number of entries in the list.
To do binary arch, we first calculate the index middle halfway between bottom and top by calculating middle=(top+bottom)/2 and then we compare the target against the key at position middle, and change one of the indices top or bottom to reduce the list to either its
彬彬有礼的读音bottom or top half. Next we note that the binary-arch process should terminate when top==bottom, that is, when the remaining part of the list contains at most the item, providing that we have not terminate earlier by finding the target.
3. Binary sort tree
温暖的时刻作文
ANSWER:
Binary sort tree is either an empty tree or a binary tree in which all the nodes in the left subtree which is not empty is less than the root node and all the nodes in the right subtree which is not empty is greater than the root node. The right subtree and the left subtree are also binary sort tree. Two examples are here below.
4. Inrtion Sort:
ANSWER:
The list can be divided into two parts. The first part is an ordered list and the cond part i
s a disordered list. The initialize situation: the first part has one entry and the cond part has n-1 entries. For ordered lists, we shall often u three new operations that have an counterparts for other lists, since they u keys rather than positions to locate the entry. One operation retrieves an entry with a specified key from the ordered list. The cond operation inrts a new entry into an ordered list by using the key in the new entry to determine where in the list to inrt it. The third operation sorts a list which may not be ordered but which has keys in its entries, so that the resulting list is ordered.
5. Selection Sort:
ANSWER:高考复读学校
Inrtion sort has major disadvantage. Even after most entries have been sorted properly into the first part of the list, the inrtion of a later entry may require that many of them be moved. All the moves made by inrtion sort are moves of only one position at a time. Thus to move an entry 20 positions up the list requires 20 parate moves. If the entries are small, perhaps a key alone, or if the entries are in linked storage, then the many mov
es may not require excessive time. But if the entries are very large, such as personnel files or student transcripts—records containing hundreds of components, and the records must be kept in contiguous storage, then it would be far more efficient if an entry being moved could immediately be placed in its final position. Our next sorting method accomplishes this goal. Selection Sort: The list can be divide into two parts. One is a sorted part and the other is an unsorted part. The initialize situation: the sorted part is an empty list. The unsorted part contain all the entries of the list.