Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
algorithmique
cours
Commits
31e592be
Verified
Commit
31e592be
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
formatting
parent
7c8c78d5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#15158
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slides/cours_13.md
+65
-9
65 additions, 9 deletions
slides/cours_13.md
with
65 additions
and
9 deletions
slides/cours_13.md
+
65
−
9
View file @
31e592be
...
...
@@ -372,6 +372,10 @@ Dans ce qui suit la taille de la table est `table_size`.
# La méthode séquentielle
\f
ootnotesize
## 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
\f
ootnotesize
## 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
\f
ootnotesize
## Comment ça marche?
*
Comme la méthode linéaire, mais
`k = h2(key)`
(variable).
```
C
...
...
@@ -434,16 +446,20 @@ h2(key) = (table_size - 2) - key % (table_size -2)
# Méthode pseudo-aléatoire
\f
ootnotesize
## 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
}
table[index].key = key;
table[index].state = OCCUPIED;
```
```C
index = h(key);
while (table[index].state == OCCUPIED && table[index].key != key) {
index = (index + random_number) % table_size;
}
table[index].key = key;
table[index].state = OCCUPIED;
```
## Comment s'assurer qu'on va bien retrouver la bonne clé?
...
...
@@ -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
\f
ootnotesize
```
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment