Académique Documents
Professionnel Documents
Culture Documents
Algorithme et Structures de
Données • Table des symboles à accès rapide
• proposé par Pugh en 1990
Wurtz Jean-Marie • Rajout de liens supplémentaires
• rechercher M rapidement :
Université Louis Pasteur
Wurtz@igbmc.u-strasbg.fr
Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley "
Reproduction ULP Strasbourg. Autorisation CFC - Paris
Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley " Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley "
Reproduction ULP Strasbourg. Autorisation CFC - Paris Reproduction ULP Strasbourg. Autorisation CFC - Paris
> >
= < • Insertion de l’élément L
> – tout d’abord recherche (cercle rouge)
– puis insertion de L avec 3 liens
– cercles noirs pointent sur L et L pointe sur les éléments précédents
(G et S au niveau 3; H et M au niveau 2)
Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley " Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley "
Reproduction ULP Strasbourg. Autorisation CFC - Paris Reproduction ULP Strasbourg. Autorisation CFC - Paris
1
private int randX() {
int i, j; double t = Math.random(); Insertion Construction d’une « Skip List »
for (i = 1, j = 2; i < L; i++, j += j)
if (t*j > 1.0) break;
if (i > lgN) lgN = i;
dans une
}
return i;
« Skip List »
private void insertR(Node t, Node x, int k) {
• t*j > 1.0 ou encore
KEY v = x.item.key();
Node tk = t.next[k]; t > 1.0/j avec j=2k
if ((tk == null) || less(v, tk.item.key())) {
if (k < x.sz) { x.next[k] = tk; t.next[k] = x; }
if (k == 0) return;
insertR(t, x, k-1); return; // Recherche niveau k-1
} •
insertR(tk, x, k); // Recherche au même niveau • Insertion des clefs : A S E R C H I N G
} • lgN : hauteur de l’arbre • Skip List initialement vide
void insert(ITEM v) • Les nœuds ont (j+1) liens) avec une
{ insertR(head, new Node(v, randX()), lgN); N++; } probabilité de 1/2j
Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley " Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley "
Reproduction ULP Strasbourg. Autorisation CFC - Paris Reproduction ULP Strasbourg. Autorisation CFC - Paris
Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley " Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley "
Reproduction ULP Strasbourg. Autorisation CFC - Paris Reproduction ULP Strasbourg. Autorisation CFC - Paris
2
Performances des algorithmes sur les arbres
Propriété des Skip List (2)
• Choix du paramètre t
• Nombre de comparaisons en moyenne
t * ( logt N ) / 2 = ( t / ( 2 * lg t ) * lg N = ( t / lg t )*( lg N /2 )
Minimum
Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley " Copyright " 'Algorithms in Java'; Robert Sedgewick & Michael Shildlowsky; Third edition, Parts 1-4; Addison-Wesley "
Reproduction ULP Strasbourg. Autorisation CFC - Paris Reproduction ULP Strasbourg. Autorisation CFC - Paris
Généralisation des 2-
2-3-4 Arbres