A hash table stores data by converting keys into array indexes using a hash function. When inserting, the key is hashed, and the resulting number is mapped to an index in the array. If the bucket at that index is empty, the key-value pair is added directly. If not, a collision occurs, and the pair is added to a list in that bucket. This example inserts three keys: "cat", "dog", and "act". "cat" and "act" collide because their hashes map to the same index, so both are stored in the same bucket list. This method allows fast insertion and lookup by reducing search to a small bucket list instead of the whole array.