Here is a short read to refresh on how to best structure a C++ program. Structure of a program – C++ Tutorials The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called “Hello World”, which simply prints “Hello World” to your computer screen. Although it is very […]
An AVL tree is a binary search tree(BST) however, unlike binary search trees, an AVL tree (named after Georgy Adelson-Velsky and Evgenii Landis) is self balancing. So no matter how many nodes you insert into the tree, it will adjust it’s branches and ensure the tree is balanced at all times. Making sure the subtree heights only differ by at most 1. […]
Here is a short insert on how to remove all Nodes of X value from a list. I use recursion and I believe I’ve created a pretty clean solution. This requires Nodes found in my earlier post. Let me know if you have any comments or improvements!
So this will pretty much wrap up our short expedition into binary trees. Remember that these functions rely on my earlier posts dealing with the class and nodes. The three types of traversals we will look at are: Preorder (root, left, right) Inorder (left, root, right) Postorder (left, right, root) Preorder Traversal This type of traversal can be used to […]
I found the basis of a print on Stackover flow the other day and changed it a little bit to be more compatible across compiler versions. Happy Coding! For some reason my code editor wouldn’t do the left slashes so below is a screenshot. Here is an example of what it will look like for the sequence 5 7 4 […]
Here is a really basic binary tree class, it just includes the basics of creating, inserting, erasing, and returning size. In later posts I will talk about printing and traversals. This class also uses the Node.h talked about in this earlier post. You’ll notice that I really like to use recursion, I think this is cleaner than looping. Let me […]
Here is just a simple example of reading a file with iostream. Just follow my comments to understand. Good luck, sometimes newlines and spaces can mess you up, you may need to utilize an ignore() or something else.
I wanted to time some functions to measure performance of different types of functions in order to find what action was optimal. Here is my code for measuring the time of a C++ action. Basically, you collect a start clock() and a end clock() then find the total time it took to perform something by taking the difference between the […]
Here is an example of a simple List class I wrote. Follow the comments to understand what is going on. This uses the node structure I wrote about here. Best of luck!
The next couple of posts are going to require the use of a node object. I’ve seen people make the node way more complicating then it should be as a class. The point of a node is to hold data and be aware of it’s neighbors. All you really need is a simple struct. In the instance of a stack or […]