The keys function returns a dictionary containing the key value pairs. key being the index number in hash table and value being the data value. Examples: 1. creating HashTable with size 10 and inserting 3 elements >>> ht = HashTable(10) >>> ht.insert
(self)
| 23 | self._keys: dict = {} |
| 24 | |
| 25 | def keys(self): |
| 26 | """ |
| 27 | The keys function returns a dictionary containing the key value pairs. |
| 28 | key being the index number in hash table and value being the data value. |
| 29 | |
| 30 | Examples: |
| 31 | 1. creating HashTable with size 10 and inserting 3 elements |
| 32 | >>> ht = HashTable(10) |
| 33 | >>> ht.insert_data(10) |
| 34 | >>> ht.insert_data(20) |
| 35 | >>> ht.insert_data(30) |
| 36 | >>> ht.keys() |
| 37 | {0: 10, 1: 20, 2: 30} |
| 38 | |
| 39 | 2. creating HashTable with size 5 and inserting 5 elements |
| 40 | >>> ht = HashTable(5) |
| 41 | >>> ht.insert_data(5) |
| 42 | >>> ht.insert_data(4) |
| 43 | >>> ht.insert_data(3) |
| 44 | >>> ht.insert_data(2) |
| 45 | >>> ht.insert_data(1) |
| 46 | >>> ht.keys() |
| 47 | {0: 5, 4: 4, 3: 3, 2: 2, 1: 1} |
| 48 | """ |
| 49 | return self._keys |
| 50 | |
| 51 | def balanced_factor(self): |
| 52 | return sum(1 for slot in self.values if slot is not None) / ( |
no outgoing calls
no test coverage detected