언젠가는 되어있겠지
데이터 공부 노트
언젠가는 되어있겠지
전체 방문자
오늘
어제
  • 분류 전체보기 (410)
    • Programming (14)
      • Python (6)
      • Algorithm (8)
    • OS (9)
      • Linux (9)
    • DBMS (2)
      • MySQL (2)
    • IoT Apps (6)
      • AppInventor (5)
      • Arduino (1)
    • LeetCode (151)
      • Easy (136)
      • Medium (13)
      • Hard (2)
    • Course (207)
      • [IBM] Data Science (9)
      • [IBM] Data Engineering (5)
      • [Inflearn] Pandas (12)
      • [Inflearn] Public Data Anal.. (8)
      • [Kaggle] Data Science (49)
      • [Youtube] Informations (2)
      • [Coursera] Machine Learning (40)
      • [Progrmiz] Data Structure A.. (15)
      • [DataQuest] Data Engineerin.. (67)
    • Data Engineering (20)
      • [Data Quest] Handling Datas.. (16)
      • [Data Quest] Data Pipeline (4)
    • Certificate (0)
      • 빅데이터 분석기사 (0)
    • SQLD (0)
    • 하고 싶은 이야기 (0)
    • 소설 (0)

블로그 메뉴

  • 홈
  • 태그

공지사항

인기 글

태그

  • Kaggle Course
  • Data Science

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
언젠가는 되어있겠지

데이터 공부 노트

[DS2] Hash Table
Course/[Progrmiz] Data Structure Algorithm

[DS2] Hash Table

2022. 8. 22. 21:17

1. Hash Table

1.1 Components

The Hash table data structure stores elements in the key-value pairs where

  • Key : unique integer that is used for indexing the values
  • Value : data that are associated with keys

1.2 Hashing

In a hash table, a new index is processed using the keys. And the element corresponding to that key is stored in the index. This process is called hashing. Let k be a key and h(x) be a hash function. Here, h(k) will give us a new index to store element linked with k.

 

1.3 Hash Collision

When the hash function generates the same index for multiple keys, thhere will be a conflict. This is called a hash collision. The solutions for hash collision are same as below :

  • Collision resolution by chaining
  • Open Addressing : Linear/Quadratic Probing and Double Hashing

Chaining

In chaining, if a hash function produces the same index for multiple elements, these elements are stored in the same index by using a doubly-linked list.

Open Addressing

In linear probing, collision is resolved by checking the next slot. $$h(k, i) = (h'(k) + i) % m$$

If a collision occurs at h(k, 0), then h(k, 1) is checked.

 

In quadratic probing, it works similar to linear probing but the spacing between the slots is increased.

$$h(k, i) = (h'(k) + c_1 i + c_2 i^2 ) % m $$

 

In double hashing, another hash funciton is calculated for finding the next slot.

$$h(k, i) = (h_1(k) + ih_2(k)) % m$$

 

1.3 Good Hash function

  1. Division Method : If k is a key and m is the size of the hash table, the hash function h(k) is calculated as h % k.
  2. Multiplication Method : \(h(k) = [m(kA \% 1)]\)
  3. Universal Hashing : hash function is chosen at random independent of keys.

 

2. Source of the contents

https://www.programiz.com/dsa/hash-table

 

Hash Table Data Structure

Hash Table In this tutorial, you will learn what hash table is. Also, you will find working examples of hash table operations in C, C++, Java and Python. The Hash table data structure stores elements in key-value pairs where Key- unique integer that is use

www.programiz.com

 

'Course > [Progrmiz] Data Structure Algorithm' 카테고리의 다른 글

[Tree DSA] Tree Data Structure  (0) 2022.09.02
[DS2] Binary Heap  (0) 2022.08.23
[DS2] Types of Linked List  (0) 2022.08.22
[DS2] Linked List  (0) 2022.08.22
[DS1] Types of Queue  (0) 2022.08.16
    'Course/[Progrmiz] Data Structure Algorithm' 카테고리의 다른 글
    • [Tree DSA] Tree Data Structure
    • [DS2] Binary Heap
    • [DS2] Types of Linked List
    • [DS2] Linked List
    언젠가는 되어있겠지
    언젠가는 되어있겠지

    티스토리툴바