public static void driver() { string s = "stone"; string target = "money"; dw = DictionaryWords.getInstance(s.Length); dict = dw.getDict(); Stopwatch sw = new Stopwatch(); sw.Start(); Stack <string> stk = GenerateLadder(s, target); if (stk.Count <= 0) { Console.WriteLine("No ladder found"); } else { Console.WriteLine("Words in ladder: "); foreach (string str in stk) { Console.WriteLine(str); } } sw.Stop(); Console.WriteLine("Time taken with stacks and queues = {0} ms", sw.ElapsedMilliseconds); }
public static DictionaryWords getInstance(int length) { if (dw == null) { lock (syncRoot) { if (dw == null) { dw = new DictionaryWords(length); } } } return(dw); }
public static DictionaryWords getInstance(int length) { if (dw == null) { lock (syncRoot) { if (dw == null) { dw = new DictionaryWords(length); } } } return dw; }
public static void driver() { string s = "stone"; string target = "money"; dw = DictionaryWords.getInstance(s.Length); dict = dw.getDict(); Stopwatch sw = new Stopwatch(); sw.Start(); Stack<string> stk = GenerateLadder(s, target); if (stk.Count <= 0) Console.WriteLine("No ladder found"); else { Console.WriteLine("Words in ladder: "); foreach (string str in stk) { Console.WriteLine(str); } } sw.Stop(); Console.WriteLine("Time taken with stacks and queues = {0} ms", sw.ElapsedMilliseconds); }
public GraphLadder(string source) { root = new Node(source); dict = DictionaryWords.getInstance(source.Length).getDict(); }