Welcome Guest [Log In] [Register]
Welcome to UCR CS 14 Klefstad.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
findPred()
Topic Started: Feb 19 2014, 05:39 PM (112 Views)
ddo006
Member Avatar

In the example slides for TreeNode * remove(key, t), there is a function called findPred(key, toRemove) that passes in a key and a tree node.
Why do we need to pass in a key? Can't we just find and return the predecessor by going to the right most child of the left subtree? ^o)

Thanks
Offline Profile Quote Post Goto Top
 
shsu007
No Avatar
Kenneth Hsu
what if the key is already in the left most tree? =O
Offline Profile Quote Post Goto Top
 
ddo006
Member Avatar

Yeah, we do need the key because if the node has no left child, there could be a node before that is a predecessor.
Edited by ddo006, Feb 20 2014, 07:12 PM.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Homework 6 · Next Topic »
Add Reply