private void button13_Click(object sender, EventArgs e) { char[] input1 = AlgorithmHelper.ConvertCommaSeparetedStringToCharArray(this.textBox1.Text); this.textBox4.Text = FindSubSequenceOfLengthTwo(input1).ToString(); this.textBox5.Text = FindSubSequenceOfLengthTwo(AlgorithmHelper.ConvertCommaSeparetedStringToCharArray(this.textBox2.Text)).ToString(); this.textBox6.Text = FindSubSequenceOfLengthTwo(AlgorithmHelper.ConvertCommaSeparetedStringToCharArray(this.textBox3.Text)).ToString(); }
private void button5_Click(object sender, EventArgs e) { //source: http://www.geeksforgeeks.org/construct-a-special-tree-from-given-preorder-traversal/ int[] preorderarray = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox5.Text); char[] leafarray = AlgorithmHelper.ConvertCommaSeparetedStringToCharArray(this.textBox4.Text); CustomNode <int> tree1 = new CustomNode <int>(); KarthicBinaryTree <int> tree = new KarthicBinaryTree <int>(); tree.Root = BuildSpecialTreeFromPreorderArray(preorderarray, leafarray, 0).treenode; string output = tree.PreOrderTraversal(tree.Root); bool result = String.Equals(this.textBox5.Text, output.Substring(0, output.LastIndexOf(',')), StringComparison.OrdinalIgnoreCase); }
private void button4_Click(object sender, EventArgs e) { char[] inorderarray = AlgorithmHelper.ConvertCommaSeparetedStringToCharArray(this.textBox2.Text); char[] preorderarray = AlgorithmHelper.ConvertCommaSeparetedStringToCharArray(this.textBox3.Text); CustomNode <char> tree = new CustomNode <char>(); KarthicBST <char> root = new KarthicBST <char>(); tree = BuildBSTreeFromInOrderAndPreOrderArray(preorderarray, 0, inorderarray, 0, inorderarray.Length - 1); //The result tree // //A // / \ // / \ // B C // / \ / // / \ / //D E F }