The issue with these binary search tree (BST) traversals is being affected by degenerate trees arises from the unbalanced structure of the tree
You can either insert values one by one by ensuring the tree is balanced otherwise the tree will go unbalanced in majority of cases
For example : If you insert 10,20,30
The tree will be like
10
20
30
Not like
20
/
10 30
Solution for this is
Using balancing strategies (e.g., AVL, Red-Black) or randomization to avoid degenerate trees.