Mark As Completed Discussion

The Pseudo-Code

The pseudo-code here is a representation of the search procedure.

Time Complexity

To find whether or not two words are adjacent, n comparisons are required, where n is the length of each word. In the worst-case scenario, all pairs of words would be compared by making (O(m^2)) comparisons. If there are m words, the time complexity is (O(m^2n)). We are using the queue data structure, which in the worst-case scenario would have m entries, making the space complexity O(mn).

Concluding Remarks

We have described a simple algorithm based on breadth first search to solve the word ladder. The algorithm can be made more efficient by pre-processing and using a more complex data structure to store an intermediate representation of words that would make searching through the dictionary more efficient and faster. However, this would be at the cost of increasing the space complexity.

TEXT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment