I'm learning the DataStructure on binary search tree part. I'm trying to print the binary tree in an inorder traversal way. On my textbook, it uses if clause to implement it. But if-clause isn't a loop.. How does it work? Is it related to using pointer root?
Also, I don't understand how the function calls itself and still works.
void dispalyInorder (treeNode *root){
if(root) {
dispalyInorder(root->left);
printf("%c", root->key);
dispalyInorder(root->right);
}
Also, when I called it on main function, I used it like this.
displayInorder(root);
And it works just fine! But I just don't understand the process.
Aucun commentaire:
Enregistrer un commentaire