Hello, thank you for the video, I was wondering if it were possible to make the function int instead of Node* and just return root->key instead of root ? thank you
@PhyleyCS3 жыл бұрын
Hi, glad you liked it! The point of the function is to return the pointer to the node with a given key (or nullptr if there's no such node), so you actually already know what the key is. The problem with returning the key is that it does not seem useful and it is not clear what should be returned if the key is not in the tree. If what you want is to just know whether the key is present in the tree, you can return a bool instead of Node *.
@haythemoldaccount79533 жыл бұрын
@@PhyleyCS oohhhh okay silly me lol, I can't believe that slipped my mind, that makes a lot more sense haha. thanks