I am building a binary search tree project and I am interested to fill up the vector by taking the order value from the binary tree(Takes a vector reference, and fills the vector with the tree values in sorted order).
The project involves many things and I tested many parts of it but I am not sure why the following pieces do not make any sense for me even though I wrote it but I still have a confusion. Basically, I want some body to point out any major problem with my code.
When coding recursive functions, I always like to write code as
1 2 3 4 5
if (base case) {
do the base case
} else {
do the recursive case
}
This ensures that you don't forget the base case, which is really easy to do. And for the binary tree, it also simplifies the code. For example, to print a subtree: