Hello,
I would like to share several questions and thoughts on problem to problem 19.8 (Find string transformation).
Should I include the max length of strings into the complexity of the solution? For each string of maximum n characters (each vertex), we need to compute all O(26 * n) = O(n) 1-character mutations. Therefore, the complexity becomes O(n * d), where d is the dictionary size (there are d words, each word needs O(n) computation). The book indeed explains that when n < d, the complexity becomes O(nd) because the number of edges drop to n. However, I think the complexity is still O(nd) even when we have a short dictionary and long strings (i.e., n >= d)
Also, although it depends on implementation, computing a hash is typically linear to length of string. Therefore, the complexity can be O(n * n * d) if we count the hashing computation costs. Do you think so?
Moreover, I guess a more efficient way for finding adjacent strings is to build a prefix tree from the dictionary.