Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Creating Hash Table with String Keys | Advanced Data Structures
course content

Course Content

Algorithms and Data Structures Overview

Challenge: Creating Hash Table with String KeysChallenge: Creating Hash Table with String Keys

A hash function is a mathematical algorithm that converts an input (or 'key') into a fixed-size value, typically a numeric value, which represents the original data in a way that facilitates efficient retrieval. The output of a hash function is called a hash code or hash value.

Task

In the previous chapter, we created a hash table with a function that can work with numerical keys. Now you will implement a hash function that will work with keys of type string.

This particular hash function must calculate the hash value by summing the ASCII values of the characters in the key string. Doing so transforms variable-length input (keys of different lengths) into a fixed-size hash value. This hash value is then modulo with the size of the hash table to determine the index where the key-value pair should be stored.

Your task is to implement this hash function by filling the gaps in the ._hash_function() method of the HashTable class.

Everything was clear?

Section 3. Chapter 5
toggle bottom row
course content

Course Content

Algorithms and Data Structures Overview

Challenge: Creating Hash Table with String KeysChallenge: Creating Hash Table with String Keys

A hash function is a mathematical algorithm that converts an input (or 'key') into a fixed-size value, typically a numeric value, which represents the original data in a way that facilitates efficient retrieval. The output of a hash function is called a hash code or hash value.

Task

In the previous chapter, we created a hash table with a function that can work with numerical keys. Now you will implement a hash function that will work with keys of type string.

This particular hash function must calculate the hash value by summing the ASCII values of the characters in the key string. Doing so transforms variable-length input (keys of different lengths) into a fixed-size hash value. This hash value is then modulo with the size of the hash table to determine the index where the key-value pair should be stored.

Your task is to implement this hash function by filling the gaps in the ._hash_function() method of the HashTable class.

Everything was clear?

Section 3. Chapter 5
toggle bottom row
some-alt