Try all possible paths using DFS, tracking the shortest path to endWord.
This explores many long paths before finding the shortest. With branching factor and depth , DFS explores up to states.
BFS finds the shortest path without exploring deeper levels prematurely.