Ah, yes - I see what you mean
A real leaf has both left and right NULL pointers
Your logic is looking better at the moment then - what results are you getting?
Ah, yes - I see what you mean
A real leaf has both left and right NULL pointers
Your logic is looking better at the moment then - what results are you getting?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I hope i get it right this time:
Code:void BST::shortestPath(node *rt,stack &s,int minHt) { if(rt == NULL) return; stack.push(rt); // store node during pre-traversal // check for whether min ht is reached and the last node is a leaf if( (minHt==0) && (rt->left == NULL) && (rt->right == NULL) ) {s.print(); // print the value of the nodes s.pop(); return;} shortestPath(rt->left,s, minHt-1); shortestPath(rt->right,s, minHt-1); s.pop(); // remove node during post-treversal }