Binary Search Trees - Print Children Function - C++ - Part 8
Вставка
- Опубліковано 4 бер 2014
- In this tutorial, we take a closer look at the binary search tree by writing a PrintChildren() function that displays the children of a parent node.
Want to learn C++? I highly recommend this book amzn.to/1PftaSt
Donate - bit.ly/17vCDFx
STILL NEED MORE HELP?
Connect one-on-one with a Programming Tutor. Click the link below:
trk.justanswer.com/aff_c?offe...
:)
Programming never seemed this easy to me. Thanks a lot!
Nice video, in case viewers are reading my comment I think the best way to handle the case if the root is NULL for the returnRoot function is to throw an exception instead of returning -1000. If you want to prove me wrong that is great.
Love you, Paul! :)
Excellent, Thank you !
dude you're awesome, thanks A LOT
dude you are very rude thanks a lot
need your help Paul and other programmers... i have a school assignment that the task is to preorder math expression to inorder using binary trees ... my knowledge in c++ on BST is very very basic and i am keep reading but couldnt find a specific algorithm to this specific task.... any help is welcome :)
One dislike is from struct
stii one ☝️
@@cjeeckazad2995 lol actually? woah there is only one dislike :O
My man.
I know this video is kinda old but i am getting repeats of the first element in array and the Conditional ? isn't working for me
Hey, I just wanted to ask, if anyone could help me figure out, why my left and right children keys are the same for every node. The key values are the same as the root children key values. Parent nodes key outputs themselves are ok.
So it goes like this:
Parent Node = 76
Left Child = 21
Right Child = 76
Parent Node = 4
Left Child = 21
Right Child = 76
Thanks in advance!
Nevermind, just an absence of the second "=" symbol. D-:
How would I get it to print the entire tree if a user is adding nodes one at a time?
+Boricuakriz u can place InOrderTraversal function inside the function that adds new item to the tree and every time u will see the updated tree
Hi, I have the same code as Paul, but only the root node's children are printed. Others say the key is not in the tree. I already cross checked my code with what Paul wrote multiple times, but I keep getting the same result. PLS HELP!!!!!!!!!!!
I thought the problem might me with my "return-node".
//**********SEARCH-PRIV************//
BST::node* BST::SearchPriv(int key, node* ptr){
if(ptr != NULL){
if(ptr->key == key){
cout
You have the following:
else{
if(ptr->key < key)
return SearchPriv(key, ptr->left);
else
return SearchPriv(key, ptr->right);
}
It should be like this:
else{
if(key < ptr->key)
return SearchPriv(key, ptr->left);
else
return SearchPriv(key, ptr->right);
}
Hopefully, this helps.
2:42 😅 I can come over and play with my house if that helps with the first time we can get the next one we have a new one in the @@hani4153046