Skip to content

Commit

Permalink
Translate Hashing in french
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshyn committed Sep 5, 2017
1 parent d3c8496 commit e59f71b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 43 deletions.
62 changes: 22 additions & 40 deletions .translations/fr/03-hashing/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# Hash function
# Fonction de hachage

In this section, we'll write our hash function.
Dans cette section, nous allons écrire notre propre fonction de hachage.

The hash function we choose should:
Cette fonction devra :

- Take a string as its input and return a number between `0` and `m`, our
desired bucket array length.
- Return an even distribution of bucket indexes for an average set of inputs. If
our hash function is unevenly distributed, it will put more items in some
buckets than others. This will lead to a higher rate of
[collisions](#collisions). Collisions reduce the efficiency of our hash table.
- Prendre une chaine de charatère en paramètre et retourner un nombre entre `0` et `m` ou m est la taille de notre tableau d'élements. Ce nombre servira d'index dans le tableau.
- Renvoyer une distribution uniforme d'index pour un ensemble de pararamètre d'entrées. Si notre fonction hash est inégalement répartie, cela entraînera un taux plus élevé de [collisions](#Données pathologiques). Les collisions réduisent l'efficacité de notre table de hachage.

## Algorithm
## Algorithme

We'll make use of a generic string hashing function, expressed below in
pseudocode.
Nous utiliserons la fonction de hachage de chaîne suivante :

```
function hash(string, a, num_buckets):
Expand All @@ -26,20 +21,15 @@ function hash(string, a, num_buckets):
return hash
```

This hash function has two steps:
Cette fonction :

1. Convert the string to a large integer
2. Reduce the size of the integer to a fixed range by taking its remainder `mod`
`m`
1. Convertie la chaîne en un entier large
2. Réduit la taille de l'entier en prenant le reste (modulo la taille du tableau).

The variable `a` should be a prime number larger than the size of the alphabet.
We're hashing ASCII strings, which has an alphabet size of 128, so we should
choose a prime larger than that.
La variable `a` doit être un nombre premier supérieur à la taille de l'alphabet utilisé. Nous effectuons nos opérations sur des chaînes ASCII, qui ont une taille d'alphabet de 128.
`char_code` est une fonction qui renvoie un entier qui représente le caractère (ASCII) passé en entré.

`char_code` is a function which returns an integer which represents the
character. We'll use ASCII character codes for this.

Let's try the hash function out:
Essayons la fonction hash:

```
hash("cat", 151, 53)
Expand All @@ -50,7 +40,7 @@ hash = (2272062) % 53
hash = 5
```

Changing the value of `a` give us a different hash function.
Changer la valeur de `a` nous donne une fonction de hachage différente.

```
hash("cat", 163, 53) = 3
Expand All @@ -71,23 +61,15 @@ static int ht_hash(const char* s, const int a, const int m) {
}
```
## Pathological data
## Données pathologiques
Une fonction de hashage idéale renverrait toujours une distribution homogènede resultat. Cependant, pour toute fonction de hachage, il existe un ensemble d'entrées «pathologiques», qui aboutit tous à la même valeur. Pour trouver ces entrées, exécutez la fonction un grand nombre de fois via la fonction. Toutes les entrées differentes qui retournent un meme resultat forment un ensemble pathologique.
An ideal hash function would always return an even distribution. However, for
any hash function, there is a 'pathological' set of inputs, which all hash to
the same value. To find this set of inputs, run a large set of inputs through
the function. All inputs which hash to a particular bucket form a pathological
set.
L'existence d'ensembles d'entrées pathologiques signifie qu'il n'existe pas de fonctions hash parfaites pour toutes les entrées. Le meilleur que nous puissions faire est de créer une fonction qui fonctionne bien pour le jeu de données attendu.
The existence of pathological input sets means there are no perfect hash
functions for all inputs. The best we can do is to create a function which
performs well for the expected data set.
Les entrées pathologiques constituent également un problème de sécurité. Si utilisateur malveillant remplit une table de hashage avec des données pathologiques, les recherches sur les clefs collisioné prendront beaucoup plus longtemps (`O(n)`) que la normale (`O (1)`).
Cela peut être utilisé comme une attaque de déni de service contre les systèmes qui se base sur des tables de hashage (DNS, web services).
Pathological inputs also poses a security issue. If a hash table is fed a set of
colliding keys by some malicious user, then searches for those keys will take
much longer (`O(n)`) than normal (`O(1)`). This can be used as a denial of
service attack against systems which are underpinned by hash tables, such as DNS
and certain web services.
Prochaine section: [Traitement des collisions](../04-collisions)
Next section: [Handling collisions](/04-collisions)
[Table of contents](https://github.com/jamesroutley/write-a-hash-table#contents)
[Table des matières](/.translations/fr/README.md#contents)
6 changes: 3 additions & 3 deletions 03-hashing/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hash function

In this section, we'll write our hash function.
In this section, we'll write our hash function.

The hash function we choose should:

Expand All @@ -9,7 +9,7 @@ The hash function we choose should:
- Return an even distribution of bucket indexes for an average set of inputs. If
our hash function is unevenly distributed, it will put more items in some
buckets than others. This will lead to a higher rate of
[collisions](#collisions). Collisions reduce the efficiency of our hash table.
[collisions](#Pathological data). Collisions reduce the efficiency of our hash table.

## Algorithm

Expand All @@ -34,7 +34,7 @@ This hash function has two steps:

The variable `a` should be a prime number larger than the size of the alphabet.
We're hashing ASCII strings, which has an alphabet size of 128, so we should
choose a prime larger than that.
choose a prime larger than that.

`char_code` is a function which returns an integer which represents the
character. We'll use ASCII character codes for this.
Expand Down

0 comments on commit e59f71b

Please sign in to comment.