Previous | Next --- Slide 46 of 66
Back to Lecture Thumbnails
Nian

Similarly, we could lock the father and current node, right?

zecheng

@Nian I think for deletion we need two. But for insertion maybe one is enough?

ajayram

@zecheng yes for deletion (example on WA4 Practice Problem), you would need 2 locks, one for the current node and one for the parent.

haiyuem

For insertion you might also need two to ensure that you don't lose the parent node that might be swapped by another insertion?

teapot

Yes, I believe that is why we need 2 locks, one for the parent node and one for the current node. This guarantees that no other thread is modifying the entire subtree with the parent node as root.

Please log in to leave a comment.