Esempio n. 1
0
        private void btnAVLTree_Click(object sender, EventArgs e) //AVL TREE BUTTON
        {
            //Declaring a new instance of AVL Tree and displaying properties to the Windows Form
            Tree1 avlTree = new Tree1("Access Time: O(log(n))", "Search Time: O(log(n))", "Insert Time: O(log(n))", "Delete Time: O(log(n))", "Space Complexity: O(n)");

            richTextBox2.AppendText(avlTree.AccessTime + "        ");
            richTextBox2.AppendText(avlTree.SearchTime + "\n");
            richTextBox2.AppendText(avlTree.InsertTime + "        ");
            richTextBox2.AppendText(avlTree.DeleteTime + "\n");
            richTextBox2.AppendText(avlTree.SpaceComplexity + "\n");
            richTextBox2.AppendText("*All Big-O values represent worst-case scenarios unless otherwise noted");

            //Displaying the Advantages and Disadvantages of AVL Tree to the Windows Form
            richTextBox1.AppendText("AVL TREES:\n");
            richTextBox1.AppendText(avlTree.Advantages("The advantages of AVL: \n" +
                                                       "   -The most prevalent benefit of AVL trees is the fact that they offer faster search operations than their counterparts such as red-black trees\n" +
                                                       "   -with AVL trees, there is a higher likelihood of them being balanced."));
            richTextBox1.AppendText("\n(AVL stands for Adelson-Velskii and Landis)");
            richTextBox1.AppendText("\n\n");
            richTextBox1.AppendText(avlTree.Disadvantages("The disadvantages of AVL: \n " +
                                                          "   -Slow inserts and deletes if slightly unbalanced.\n" +
                                                          "   -Don't work well with systems that update quickly and regularly."));

            //Displaying extra notes from a rich text file in the bin
            using (StreamReader Reader = new StreamReader(@"C:\Users\Clayt\source\repos\CSC205\CSC205_StudyProject\CSC205_StudyProject\bin\AVLTree.rtf"))
            {
                while (!Reader.EndOfStream)
                {
                    richTextBox5.AppendText(Reader.ReadLine());
                }
            }
        }
Esempio n. 2
0
        private void btnRedBlackTree_Click(object sender, EventArgs e) //RED-BLACK TREE BUTTON
        {
            //Declaring a new instance of Red-Black Tree and displaying properties to the Windows Form
            Tree1 redBlackTree = new Tree1("Access Time: O(log(n))", "Search Time: O(log(n))", "Insert Time: O(log(n))", "Delete Time: O(log(n))", "Space Complexity: O(n)");

            richTextBox2.AppendText(redBlackTree.AccessTime + "        ");
            richTextBox2.AppendText(redBlackTree.SearchTime + "\n");
            richTextBox2.AppendText(redBlackTree.InsertTime + "        ");
            richTextBox2.AppendText(redBlackTree.DeleteTime + "\n");
            richTextBox2.AppendText(redBlackTree.SpaceComplexity + "\n");
            richTextBox2.AppendText("*All Big-O values represent worst-case scenarios unless otherwise noted");

            //Displaying the Advantages and Disadvantages of Red-Black Tree to the Windows Form
            richTextBox1.AppendText("RED-BLACK TREES\n");
            richTextBox1.AppendText(redBlackTree.Advantages("Red-Black Tree is a self-balancing " +
                                                            "Binary Search Tree (BST) where every node follows following rules.\n" +
                                                            "   -Every node has a color either red or black.\n" +
                                                            "   -Root of tree is always black.\n" +
                                                            "   -There are no two adjacent red nodes (A red node cannot have a red parent or red child).\n" +
                                                            "   -Every path from a node (including root) to any of its descendant NULL node has the same number of black nodes.\n" +
                                                            "Red-Black Trees are designed such that as elements are added or " +
                                                            "removed, the whole tree shifts to accommodate the change. It keeps the tree balanced so that you can search the tree very fast."));
            richTextBox1.AppendText("\n\n");
            richTextBox1.AppendText(redBlackTree.Disadvantages("The disadvantages of Red-Black Tree: \n" +
                                                               "   -can be complicated to implement."));

            //Displaying extra notes from a rich text file in the bin
            using (StreamReader Reader = new StreamReader(@"C:\Users\Clayt\source\repos\CSC205\CSC205_StudyProject\CSC205_StudyProject\bin\RedBlackTree.rtf"))
            {
                while (!Reader.EndOfStream)
                {
                    richTextBox5.AppendText(Reader.ReadLine());
                }
            }
        }
Esempio n. 3
0
        private void btnBinarySeacrh_Click(object sender, EventArgs e) //BINARY SEARCH TREE BUTTON
        {
            //Declaring a new instance of Binary Search Tree and displaying properties to the Windows Form
            Tree1 tree1 = new Tree1("Access Time: O(n)", "Search Time: O(n)", "Insert Time: O(n)", "Delete Time: O(n)", "Space Complexity: O(n)");

            richTextBox2.AppendText(tree1.AccessTime + "        ");
            richTextBox2.AppendText(tree1.SearchTime + "\n");
            richTextBox2.AppendText(tree1.InsertTime + "        ");
            richTextBox2.AppendText(tree1.DeleteTime + "\n");
            richTextBox2.AppendText(tree1.SpaceComplexity + "\n");
            richTextBox2.AppendText("*All Big-O values represent worst-case scenarios unless otherwise noted");

            //Displaying the Advantages and Disadvantages of Binary Search Tree to the Windows Form
            richTextBox1.AppendText("TREES\n");
            richTextBox1.AppendText(tree1.Advantages("A tree is a data structure composed of nodes.\n" +
                                                     "   - Each tree has a root node.\n" +
                                                     "   - The root node has zero or more child nodes.\n" +
                                                     "   - Each child node has zero or more child nodes, and so on.\n" +
                                                     "The tree cannot contain cycles.The nodes may or may not be in a particular order, " +
                                                     "they could have any data type as values, and they may or may not have links back to their " +
                                                     "parent nodes.A node is called a “leaf” node if it has no children."));
            richTextBox1.AppendText("\n\n");
            richTextBox1.AppendText("Binary Search Tree(BST): \n" +
                                    "   -BSTs are the best options when trying to optimize for efficient searching and flexible updates. " +
                                    "The best / worst cases are differentiated by how well balanced the tree is. Balanced trees are more " +
                                    "efficient than unbalanced trees\n");
            richTextBox1.AppendText(tree1.Disadvantages("\nThe disadvantages of Binary Search Tree: \n" +
                                                        "   -BSTs have more overhead and complexity to initialize and maintain.\n" +
                                                        "   -The main disadvantage is that we should always implement a balanced binary search tree: AVL tree, " +
                                                        "Red-Black tree, Splay tree. Otherwise the cost of operations may not be logarithmic and degenerate " +
                                                        "into a linear search on an array."));

            //Displaying extra notes from a rich text file in the bin
            using (StreamReader Reader = new StreamReader(@"C:\Users\Clayt\source\repos\CSC205\CSC205_StudyProject\CSC205_StudyProject\bin\BinarySearchTree.rtf"))
            {
                while (!Reader.EndOfStream)
                {
                    richTextBox5.AppendText(Reader.ReadLine());
                }
            }
        }