public static void TakeRequest(int requesthandle) { try { switch (requesthandle) { case 1: if (NodeData.GetChildren().Count == 0) { Console.WriteLine("Enter the Data for Root Node:"); int data = Int32.Parse(Console.ReadLine()); NodeData.data = data; NodeData.Level = 0; Console.WriteLine("Root Node Created, Key in the number of children and the data for each, all separeated by space --> <numchild> <val1> <val2> <val3>...:"); int[] invals = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray(); for (int i = 0; i <= invals[0] - 1; i++) { Node child = new Node(invals[i + 1], 1, NodeData); NodeData.AddChildNode(child); } Console.WriteLine("Creation Successful"); } else { Console.WriteLine("Key in the Values--> <Level> <Parent_Node_Data> <numchild> <val1> <val2> <val3>...:"); int[] invals = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray(); //get the node at that level with the data mentioned for that node //We can get that recursively... Node InsertNode = null; if (invals[0] == 0) { InsertNode = NodeData.GetNode(); } else { GetNode(ref NodeData, invals[0], invals[1], ref InsertNode); } if (InsertNode != null) { for (int i = 0; i <= invals[2] - 1; i++) { Node child = new Node(invals[i + 3], invals[0] + 1, InsertNode); InsertNode.AddChildNode(child); } Console.WriteLine("Creation Successful"); } } break; case 2: Console.WriteLine("Key in the values--> <Level> <Node_Data>:"); int[] inpvals = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray(); //get the node at that level with the data mentioned for that node //We can get that recursively... Node InNode = null; GetNode(ref NodeData, inpvals[0], inpvals[1], ref InNode); InNode.GetParent().RemoveChildNode(InNode); Console.WriteLine("Removal Successful"); break; case 3: if (NodeData.GetChildren().Count > 0) { GenerateTree(); } else { Console.WriteLine("Create Tree in order to view it"); } break; } } catch (Exception ex) { throw ex; } }