May 2017
Intermediate to advanced
310 pages
8h 5m
English
In our example, the hash table's size was set to 256. Obviously, as we add elements to the list, we begin to fill up the empty slots. At some point, all the slots will be filled up and the table will be full. To avoid this, we can grow the table when it is getting full.
To do this, we compare the size and the count. Remember that size held the total number of slots and count the number of those slots that contained elements? Well, if count equals size then we have filled up the table.
The hash table's load factor gives us an indication of how large a portion of the available slots are being used. It is defined as follows:
As the load factor approaches 1, we need to grow the table. In fact, we should do it before it gets ...