31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

void D.del(const K& k) deletes the item with key k from the set (null<br />

operation, if no such item exists).<br />

void<br />

D.del item(pp dic item it)<br />

removes item it from the set.<br />

Precondition: it is an item in the set.<br />

pp dic item D.change inf(pp dic item it, const I& i)<br />

makes i the information of item it. This may<br />

create a new item; the item in<br />

the new set is returned.<br />

Precondition: it is an item in the set.<br />

void D.clear( ) makes D the empty dictionary.<br />

3.2 Access operations<br />

const K&<br />

D.key(pp dic item it) returns the key of item it.<br />

Precondition: it ∈ D.<br />

const I& D.inf(pp dic item it) returns the information of item it.<br />

Precondition: it ∈ D.<br />

pp dic item D.lookup(const K& k)<br />

pp dic item D.locate succ(const K& k)<br />

pp dic item D.locate pred(const K& k)<br />

int D.size( ) returns the size of D.<br />

returns the item with key k (nil if no such item<br />

exists in D).<br />

returns the item x in D so that key(x) =<br />

min{key(y)| y ∈ D ∧ key(y) ≥ k}.<br />

returns the item x in D so that key(x) =<br />

max{key(y)| y ∈ D ∧ key(y) ≤ k}.<br />

bool D.empty( ) returns true if D is empty, false otherwise.<br />

4. Implementation<br />

Partially persistent dictionaries are implemented by leaf oriented partially persistent redblack<br />

trees. Operations insert, del, del item and lookup take expected time O(log n), the<br />

expected time for key, inf, empty, size and change inf is O(1), and clear takes expected<br />

time O(n). Here n is the number of items in the version of the dictionary to which the<br />

operation is applied. <strong>The</strong> expected space requirement is O(1) for each update operation.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!