Post

Hash Table

✅ Hash Table

Data structure used to insert, look up, remove key-value pairs
operates on hashing concept

✔️ Hash function

function to change input into keys

⭐️ Keyword

✅ Code

input, output

1
2
3
4
5
6
7
8
9
10
11
12
13
//input
5
abcd
abc
abcd
abcd
ab
//output
OK
OK
abcd1
abcd2
OK
  1. set
    • HASH_SIZE
    • HASH_LEN
    • HASH_VAL: prime number for avoiding collision
  2. configure getHashKey method for changing input into keys
  3. save keys value into array data
  4. configure checking method for checking if there is a saved keys value on array data
  5. when a new string is given, check array data
    • if there is saved keys check if this string has been input before.
      • if there is, print string with “string + count”
      • if there is not, print “OK”
    • if there is not saved keys, add to array data

💡 Reference

https://gyoogle.dev/blog/algorithm/Hash%20Table.html

This post is licensed under CC BY 4.0 by the author.