Understanding Recursive Data Structures.
- Windows 10 / Mac
- c++11
Essentially, this aims to create a Binary Search Tree in C++, which can be implemented to solve and display Arithmetic Expressions of two possible forms: "A+B" and "AB*" where the operator is positioned to a particular form. This was also intended to test my understanding of other useful data structures such as Stacks and Queues. With this in mind, I was hoping to better understand how a compiler might possibly analyze and parse syntax through a trivial approach.
Visual |
A possible visual interpretation of how an algebraic expression of a particular form utilizes two stacks for distinguishing between operators and operands while treating a subset of an expression as its own subtree, effectively creating a tree while performing traversals and evaluations all in O(N).
Implementation |
- Arithmetic Expressions can be displayed appropriately with balanced parentheses such as:
- ((((A+B)-C)+D)*E) or ((4* 2)*(3+6)) where each inner node is an operator and every leaf is an operand.
- Secondly, while this program is minimal, it does attempt to implement a Map using a BST with key-value pairs of the form:
- (Key, Value)
If you have a suggestion for what should be improved, your contributions will be greatly appreciated. Simply:
- Fork the Project
- Create your Feature Branch
- Commit your Changes
- Push to the Branch
- Open a Pull Request
@donnolis
I particularly do not have any links to the sources I used in creating this, but these for sure played a crucial role.
- Stackoverflow
- Geeksforgeeks
- Progamiz
- A C++ textbook
There are perhaps a lot of issues as I didn't really choose to test how certain inputs would break my already buggy code, but for the most part, everything seems to work. Again, this is by no means professional as I was simply messing around and shoving concepts together.
Out of Boredom and curiosity, this is my Creation.