Re: Deletion in red black tree

43 views
Skip to first unread message

Mehreen Saeed

unread,
Jun 6, 2015, 10:10:53 AM6/6/15
to asim mehmood, dsfas...@googlegroups.com
Asim

I am not sure I understand the question.  But if you want to delete a key whose node has two child nodes then

1. look for the highest key in the left subtree OR lowest key in the right subtree.
2. Save this key and delete the node with this key (you will need to apply deletion cases here)
3. Replace the key you want to delete with this saved key

You should have implemented this case in your assignment also.

Mehreen

On Sat, Jun 6, 2015 at 3:33 PM, asim mehmood <asim...@gmail.com> wrote:
Madam,



In a red black tree we have to delete a node which have 2 child node.Then, will we have to consider all cases of red black tree? Because there is written in handouts slides of deletion you that we are not handling case c here. If it is so, then we will no longer have a red black tree.

if we are handling case c then which will be our "node"  "N" on which we will apply all cases after deletion the node
1. The highest key in left?

2. The node we actually want to delete.




Mehreen Saeed

unread,
Jun 7, 2015, 1:51:29 PM6/7/15
to asim mehmood, dsfas...@googlegroups.com
Your node is the highest key on the left OR lowest key in right subtree.  Apply all cases to delete this node.

On Sun, Jun 7, 2015 at 9:20 PM, asim mehmood <asim...@gmail.com> wrote:

mam
what will be our "node"  in this case. on which we will be applying cases.

Reply all
Reply to author
Forward
0 new messages