public void Run() { Console.WriteLine("Select the operation: "); Console.WriteLine("1. Serialize Tree"); Console.WriteLine("2. Deserialize"); int option = Convert.ToInt32(Console.ReadLine()); Node node = new Node { Data = 50, LeftNode = new Node { Data = 30, LeftNode = new Node { Data = 15 }, RightNode = new Node { Data = 35, RightNode = new Node { Data = 40, LeftNode = new Node { Data = 36 } } } }, RightNode = new Node { Data = 70, RightNode = new Node { Data = 90 } } }; string serializedTree = "50 30 15 35 40 36 70 90"; switch (option) { case 1: Console.WriteLine(Serialize(node)); break; case 2: TreeTraversals app = new TreeTraversals(); app.Node = Deserialize(serializedTree); app.Run(); break; } Console.ReadLine(); }
public static void Orquestrator() { Console.WriteLine("Select the program you want to run"); Console.WriteLine("1. M-th to last"); Console.WriteLine("2. Ladders and Snakes"); Console.WriteLine("3. Utopian Tree"); Console.WriteLine("4. Pangrams"); Console.WriteLine("5. Tree Traversals"); Console.WriteLine("6. Dynamic Arrays *Not working*"); Console.WriteLine("7. 2D Array"); Console.WriteLine("8. Spare Arrays"); Console.WriteLine("9. Distances"); Console.WriteLine("10. Bit Manipulation"); Console.WriteLine("11. Binary Search Tree"); Console.WriteLine("12. Array list"); Console.WriteLine("13. Tower of Hanoi"); Console.WriteLine("14. AVL Trees"); var option = Convert.ToInt32(Console.ReadLine()); IProgram program; switch (option) { case 1: program = new MthToLast(); break; //case 2: // //program = new SnakesAndLadders(); // break; case 3: program = new UtopianTree(); break; case 4: program = new Pangrams(); break; case 5: program = new TreeTraversals(); break; case 6: program = new DynamicArray(); break; case 7: program = new _2DArray(); break; case 8: program = new SparesArrays(); break; case 9: program = new Distances(); break; case 10: program = new BitManipulation(); break; case 11: program = new BinarySearchTree(); break; case 12: program = new ArrayList(); break; case 13: program = new TowerOfHanoi(); break; case 14: program = new AVL(); break; default: program = new MthToLast(); break; } program.Run(); }