Скачиваний:
24
Добавлен:
09.09.2020
Размер:
1.81 Mб
Скачать

Open Addressing (Linear Probing)

Insert "John Doe" with ID = 123 hash(123) = 1

hash(123) = 1

Student hash()

Name John Doe

GPA 2.8

ID 123

Data1

0

2

3

4

Open Addressing (Linear Probing)

Insert "John Doe" with ID = 123 hash(123) = 1

data[1] is empty, no collision

 

 

 

Data1

 

 

hash(123) = 1

0

 

 

 

2

 

Student

hash()

3

 

 

 

Name

John Doe

 

4

GPA

2.8

 

 

ID

123

 

 

Open Addressing (Linear Probing)

Добавить "John Doe" with ID = 123 hash(123) = 1

data[1] пустая, нет коллизий Сохранить её

hash(123) = 1

hash()

Student

Name John Doe

GPA 2.8

ID 123

Data

0

John Doe

 

 

2.8

 

 

 

1

123

 

 

 

2

 

 

3

 

 

4

 

Open Addressing (Linear Probing)

Hash Table содержит одну запись

Data

0

1

2

3

4

John Doe

2.8

123

Open Addressing (Linear Probing)

Добавить "Jane Doe" with ID = 202

 

Data

 

0

 

1

 

2

Student

3

Name

4

Jane Doe

GPA

3.4

ID

202

John Doe

2.8

123

Open Addressing (Linear Probing)

Insert "Jane Doe" with ID = 202 hash(202) = 3

hash()

Student

Name

Jane Doe

GPA

3.4

ID

202

Data

0

1

hash(202) = 3

2

3

4

John Doe 2.8 123

Open Addressing (Linear Probing)

Insert "Jane Doe" with ID = 202 hash(202) = 3

data[3] is empty, no collision

hash()

Student

Name

Jane Doe

GPA

3.4

ID

202

Data

0

1

hash(202) = 3

2

3

4

John Doe 2.8 123

Open Addressing (Linear Probing)

Insert "Jane Doe" with ID = 202 hash(202) = 3

data[3]store it istherempty, no collision

hash()

Student

Name

Jane Doe

Data

0

1

hash(202) = 3

2

3

4

John Doe 2.8 123

Jane Doe 3.4 202

Open Addressing (Linear Probing)

Hash Table таблица содержит 2 записи

Data

0

1

2

3

4

John Doe

2.8

123

Jane Doe 3.4 202

Open Addressing (Linear Probing)

Добавить "Some Guy" with ID = 401

 

Data

 

0

 

1

 

2

Student

3

Name

4

Some Guy

GPA

3.5

ID

401

John Doe 2.8 123

Jane Doe 3.4 202

Соседние файлы в папке лекции