Python module implementing a partitioned linked-list/AVL-tree morphing dictionary, i.e. a data structure that manages key-value pairs where the keys are integers partitioned into a fixed number of blocks, each one associated with a linked list or an AVL tree depending on its size. First essay paper of Algorithm Engineering course.
Given the following parameters in the set of integers
-
$min$ and$max$ such that$max > min$ $r = 6$ -
$b > r$ such that$\left( max - min \right)$ is a multiple of$b$
Let's define
From the previous definitions it can be seen that
Implement a data structure that manages pairs of type
- an array
$v$ of size$d + 2$ where each cell is indexed by$i \in \left\{ 0, \ldots, d + 1\right\}$ and points to a known data structure (linked list or AVL tree) with$n_i$ elements-
$v\left[ i \right]$ points to a linked list$\Leftrightarrow n_i < r$ -
$v\left[ i \right]$ points to an AVL tree$\Leftrightarrow n_i \ge r$
-
- implements the
insert(key, value)
,delete(key)
,search(key)
methods of theDictionary
abstract class- operations are performed on the data structure pointed to by
$v\left[ i \right] \Leftrightarrow key \in B_i$ with$i \in \left\{ 0, \ldots, d + 1 \right\}$
- operations are performed on the data structure pointed to by
N.B.: the insert
and delete
operations modify the number
Finally, experimentally compare the average execution time of the methods search
and delete
of the
previously described data structure and of the Python dictionary
with respect to the number