This code serves as a demonstration of my C++ knowledge. I decided to test myself by completing a EEE (Electronics and Electrical Engineering) computing assignment.
The aim of the assignment was to first create a Binomial tree using a vector of strings containing the true branches.
Following an input of:
std::vector<std::string> fv;
std::string row;
row = "11";
fv.push_back(row);
BoolTree ft1(fv);
The program should store the following tree in ft1
The second part of the assignment was to simplify the binomial tree. This meant that if a node's two branches were identical, the node should become either branch.
To complete this assignment I saw no other option than using recursive functions.
I decomposed the problem into several steps:
- Construct the tree
- Construct a
0- filled tree - Change the tree to include the
true/1values
- Construct a
- Simplify the tree
- Given a node, compare if both branches are identical
- If identical, change the current node to one of the branches
- If different, do the analysis on both branches
To verify whether the construction of the tree was correctly done, I wrote get_string(), a function that given a node it's branches' nodes from left to right.
I was able to use this function in the simplification process by
- Getting the string of a node
- Removing the current node's value
- Separating the resultant string into 2 string (left branch and right branch)
- Comparing both left and right strings

