Red black tree deletion

67 views
Skip to first unread message

Ghulam Rasool

unread,
Jun 7, 2015, 9:53:16 AM6/7/15
to dsfas...@googlegroups.com


Mam in this example.. by applying case 3: Node with 2 childs.. find highest key on left which is 0..we replace it with N and then delete 0 place..and we are done.. but in this handout you have applied case 1(adjust node) case for leaf node..and made 6 red.. kindly explain in me what's going on..Thanks

Mehreen Saeed

unread,
Jun 7, 2015, 10:20:12 AM6/7/15
to Ghulam Rasool, dsfas...@googlegroups.com
Ghulam Rasool. 
1. Find the highest key in the left subtree of 1.  The highest key is zero. 
2. Delete zero.  So apply all cases for deletion to this node.  That is why 6 is now red. 
3. As the last step after deleting zero replace the 1 with zero and you are done.

Mehreen


On Sun, Jun 7, 2015 at 6:53 PM, Ghulam Rasool <gr.m...@gmail.com> wrote:


Mam in this example.. by applying case 3: Node with 2 childs.. find highest key on left which is 0..we replace it with N and then delete 0 place..and we are done.. but in this handout you have applied case 1(adjust node) case for leaf node..and made 6 red.. kindly explain in me what's going on..Thanks

--
You received this message because you are subscribed to the Google Groups "DSFAST2015" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dsfast2015+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dsfast2015/1b18c3ca-6912-42f5-b95c-4f45c0a63874%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ghulam Rasool

unread,
Jun 7, 2015, 10:39:43 AM6/7/15
to dsfas...@googlegroups.com
thanQ Ma'am.. now i get it..

Moiz Nasir

unread,
Jun 7, 2015, 10:57:20 AM6/7/15
to Ghulam Rasool, dsfas...@googlegroups.com
But Ma'am, this is case C, and we do not have to check for the cases of deletion in it. Then why are we doing so in this case?

--
You received this message because you are subscribed to the Google Groups "DSFAST2015" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dsfast2015+...@googlegroups.com.

Moiz Nasir

unread,
Jun 7, 2015, 11:11:14 AM6/7/15
to Ghulam Rasool, dsfas...@googlegroups.com
ma'am, deleting 1 is case C. We aren't supposed to check cases for deletion in this case. So why are we doing so in this example?

On Sun, Jun 7, 2015 at 7:39 PM, Ghulam Rasool <gr.m...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "DSFAST2015" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dsfast2015+...@googlegroups.com.

Mehreen Saeed

unread,
Jun 7, 2015, 1:48:11 PM6/7/15
to Moiz Nasir, Ghulam Rasool, dsfas...@googlegroups.com
Yes, but you have to check all cases for deleting zero.

Mehreen

Ghulam Rasool

unread,
Jun 7, 2015, 1:51:42 PM6/7/15
to dsfas...@googlegroups.com
of course we are deleting 1.. applying case 3..
1. find highest key in the left subtree..in this case is 0..ok
savekey=highestkeyonleft(n);
2. perform deletion on that node.. as u see 0 node is a leaf node.. so we apply adjust node..
delete(savekey);
3. after that.. we just do n->data=savekey

i hope now u get it.

On Sunday, 7 June 2015 18:53:16 UTC+5, Ghulam Rasool wrote:
Reply all
Reply to author
Forward
0 new messages