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
- set
- HASH_SIZE
- HASH_LEN
- HASH_VAL: prime number for avoiding collision
- configure
getHashKey
method for changinginput
intokeys
- save
keys
value into arraydata
- configure
checking
method for checking if there is a savedkeys
value on arraydata
- 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, print string with “string + count”
- if there is not saved
keys
, add to arraydata
- if there is saved
💡 Reference
This post is licensed under CC BY 4.0 by the author.