Skip to content
Snippets Groups Projects
Verified Commit 31e592be authored by orestis.malaspin's avatar orestis.malaspin
Browse files

formatting

parent 7c8c78d5
Branches
No related tags found
No related merge requests found
Pipeline #15158 passed
......@@ -372,6 +372,10 @@ Dans ce qui suit la taille de la table est `table_size`.
# La méthode séquentielle
\footnotesize
## Comment ça marche?
* Quand l'index est déjà occupé on regarde sur la position suivante, jusqu'à en
trouver une libre.
......@@ -392,6 +396,10 @@ table[index].state = OCCUPIED;
# Méthode linéaire
\footnotesize
## Comment ça marche?
* Comme la méthode séquentielle mais on "saute" de `k`.
```C
......@@ -413,6 +421,10 @@ Cette méthode répartit mieux les regroupements au travers de la table.
# Méthode du double hashing
\footnotesize
## Comment ça marche?
* Comme la méthode linéaire, mais `k = h2(key)` (variable).
```C
......@@ -434,12 +446,16 @@ h2(key) = (table_size - 2) - key % (table_size -2)
# Méthode pseudo-aléatoire
\footnotesize
## Comment ça marche?
* Comme la méthode linéaire mais on génère `k` pseudo-aléatoirement.
```C
index = h(key);
while (table[index].state == OCCUPIED && table[index].key != key) {
index = (index + random_number) % table_size; // attention à pas dépasser
index = (index + random_number) % table_size;
}
table[index].key = key;
table[index].state = OCCUPIED;
......@@ -461,6 +477,46 @@ table[index].state = OCCUPIED;
# Méthode quadratique
* La fonction des indices de collision est de degré 2.
* Soit $J_0=h(key)$, les indices de collision se construisent comme:
```C
J_i = J_0 + i^2 % table_size, i > 0,
J_0 = 100, J_1 = 101, J_2 = 104, J_3 = 109, ...
```
## Problème possible?
. . .
* Calculer le carré peut-être "lent".
* En fait on peut ruser un peu.
# Méthode quadratique
\footnotesize
```C
J_i = J_0 + i^2 % table_size, i > 0,
J_0 = 100
\
d_0 = 1
/ \
J_1 = 101 Delta = 2
\ /
d_1 = 3
/ \
J_2 = 104 Delta = 2
\ /
d_2 = 5
/ \
J_3 = 109 Delta = 2
\ /
d_3 = 7
/
J_4 = 116
J_{i+1} = J_i + d_i,
d_{i+1} = d_i + Delta, d_0 = 1, i > 0.
```
# Méthode de chaînage
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment