| 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: |
| findPred() | |
|---|---|
| Tweet Topic Started: Feb 19 2014, 05:39 PM (112 Views) | |
| ddo006 | Feb 19 2014, 05:39 PM Post #1 |
|
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? Thanks |
![]() |
|
| shsu007 | Feb 20 2014, 12:22 PM Post #2 |
Kenneth Hsu
|
what if the key is already in the left most tree? =O |
![]() |
|
| ddo006 | Feb 20 2014, 06:59 PM Post #3 |
|
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.
|
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Homework 6 · Next Topic » |






12:15 PM Jul 11