Category : binary-tree

My exercise is to Insert Elements in BSTree and Find the Max element of it. After I did that, It is not printing anything and always return 0. I tried with Print Function but it was same i don’t know the reason . Please help. Thanks in advance …………………………………………………………………………………………………………………………………………. #include <iostream> using namespace std; struct ..

Read more

I am trying to write a function that returns the number of leaf nodes in a binary tree in C++. However, I keep getting an error "exited, segmentation fault" Here is the code that I have written: template <class elemType> int binaryTreeType<elemType>::leavesCount(binaryTreeNode<elemType> *p) const { if (p->llink==NULL && p->rlink==NULL){ return 1; } return leavesCount(p->llink) + ..

Read more