10.4. Dynamization for Worst-Case Performance

10.4. Dynamization for Worst-Case Performance

In the previous section, you saw that it is easy to amortize the cost of Insert and Delete analytically over time. The main idea for the construction of the dynamic data structure was given by the binary decomposition of W , which has fundamental changes from time to time, but the corresponding costs were amortized. Now, we are looking for the worst-case cost of Insert and Delete. The idea is to distribute the construction of V j itself over time; i.e., the structure V j should be finished if V j ˆ 1 , V j ˆ 2 , V has to be erased.

More precisely, we want to demonstrate that the given ideas can also be adapted for running under a cost model that measures every single operation in the worst case. The main ideas stem from [Overmars and van Leeuwen 81a, Overmars and van Leeuwen 81d].

For convenience, we consider the insert operation first. After a sequence of insert operations, we have to reconstruct the binary decomposition. Obviously, if this happens, the corresponding insert operation takes a lot of effort. Therefore, we will try to build up the new structure stepwise until the structure is already completed in the case of the last insertion.

The main idea is that every V i is split into at most four structures: V i 1 , V i 2 , V i 3 , and V i * with 2 i objects, respectively. V i * is under construction. The general rule is as follows . If V i 1 is full and we insert objects into V i 2 for the first time, we start inserting the objects of V i 1 and V i 2 into V i +1 *, a structure of size 2 i +1 . This is spread over the next 2 i +1 insertions into V i 2 and V i 3 . Then, V i +1 * is full and replaces V i +1 1 in the next insertion step. The second rule is that we successively replace image from book , image from book , or image from book with V i *, if V i * is full. The replacement takes constant time.

For convenience, we consider a sequence of insertions into an empty structure. The steps can be seen in Figure 10.11.

image from book
Figure 10.11: Spreading reconstruction over time.
  1. The first object a is inserted into V 01 . The next object b is inserted into V 02 . At the same time, application of the simple rule above requires that the first element of V 01 = a is inserted into V 1 *.

  2. c is inserted into V 03 . At the same time, V 02 = b is inserted into V 1 * , and V 1 * is finished for the first time. That is, we successively build up V 1 * from the elements of V 01 and V 02 after two insertions.

  3. If the next element d has to be inserted, V 01 , V 02 , and V 03 are already full. Now, V 11 is replaced by V 1 * and V 01 is replaced by V 03 , and the new element d is inserted into V 03 . This again means that we start to build a new V 1 * with elements of V 01 and V 02 , and c is inserted into V 1 *.

  4. The next element e is inserted into V 03 , and at the same time, d is inserted into V 1 *, which is completed then.

  5. If the next element f is inserted, V 12 is replaced by V 1 *. With respect to the above rule, the first part of V 2 * is constructed with the first element of V 11 , which is a .

  6. The element g is inserted into V 03 , V 1 * is completed, and V 2 * has half-size.

  7. V 1 * replaces V 13 , if h is inserted. Again, we start with a new construction of V 1 * by inserting V 01 = g .

  8. If i is inserted into V 03 , the structure V 2 * is completed after the 2 2 insertions, namely of f , g , h , and i . Again, V 1 * is completed also.

  9. In the next step, V 2 * replaces V 21 . Additionally, V 13 replaces V 11 and V 1 * is moved to V 12 . Therefore, we also start to build up V 1 * again from V 11 and V 12 .

The structure V i +1 * is completed after 2 i +1 insert operations. Altogether, for every single insert operation, we invest

image from book

time for the construction of V i +1 *. Of course, we still need to sum up the cost for all structures V i *. The cost can be analyzed analogously to the amortized cost in Section 10.3.1. The only difference to the amortized cost model is that the work has to be partially done if the insert operations occurs.

The structures V i 1 , V i 2 and V i 3 are either full or empty. For the query operation, all full structures V i 1 , V i 2 , and V i 3 are in use.

We have to take care that the Build and Collect operations can be split into small steps; otherwise , we cannot distribute the work adequately.

A worst-casesensitive delete operation for the binary decomposition can be implemented as follows. We start to reconstruct a better copy V of each of the single structures V if the number of all (real data and weakly deleted elements) objects n in V equals approximately 3/2 times the number of the real data objects in V . If the number of all (real data and weakly deleted elements) objects n of V rise to approximately two times the number of the real data objects, V should should be ready to replace V .

The structures V i 1 , V i 2 , and V i 3 may have weakly deleted elements. For a single WeakDelete, we will find the corresponding substructure by a balanced search tree, as shown in the previous section. As explained earlier, we start to reconstruct V ij in a copy image from book if 1/4 of the structure V ij is non-real . If the half-size of the structure V ij becomes non-real, we replace V ij by image from book . We have to take care that image from book is fully completed if the half-size limit is reached. The worst case is that after the start of constructing image from book , only WeakDelete operations occur. In any case, at least 1/4 V ij WeakDelete operations can be used to build image from book . Therefore, the cost b V ( V ij ) is spread over 1/4 V ij WeakDelete operations, and each operation is charged with cost

image from book

The main difference from the amortized cost model is that the work has to be partially done if the WeakDelete operation occurs.

There is one special problem here. Some of the real objects of V ij that were already inserted in the copy image from book may be weakly deleted before image from book is ready. During the reconstruction of V ij in image from book , we cannot perform a WeakDelete on the copy image from book . Therefore, we store the WeakDelete operations on V ij in a queue and apply them afterwards to image from book . Thus, if V ij is replaced by image from book , it may have some weakly deleted objects. But it can be guaranteed by simple arithmetic that less than 25 per cent of the new structure is non-real. There is also a special problem with V i *. We cannot weakly delete elements from image from book , because we still have to construct it. Therefore, for V i *, we also store the WeakDelete operations on image from book and image from book in a queue and apply them afterwards to V i *.

We refer the interested reader to [Klein 05] and [Overmars 83] for more information.

Theorem 10.5. A static abstract data type Static , as presented in Figure 10.10 with an additional operation V . WeakDelete( d ) and with additional cost function wd V ( n ) , can be dynamized in a dynamic abstract data type DYNAMIC so that

image from book

Here, n denotes the number actual data objects.



Geometric Data Structures for Computer Graphics2006
Geometric Data Structures for Computer Graphics2006
ISBN: N/A
EAN: N/A
Year: 2005
Pages: 69

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net