I want to understand this problem... This is the code I wrote to simulate the standard implementation. The standard implementation is to first confirm that the element exists in the red-black tree and then delete it; mine is to delete it directly, regardless of whether it exists or not. For the time being. There is no test, but it is basically the same as the standard code implementation
The idea of deletion is similar to the idea of deleting the minimum and maximum values. The previous thinking was limited to how to simulate the deletion of 2-3 trees and did not recognize the relationship between them clearly...
I want to ask the poster a question In the process of moving to the right branch in delete, the moveRedRight method is called Excuse me why in the moveRedRight method node = rotateRight(node); flipColors(node); After these two steps are executed Why is there no need to perform left rotation? It stands to reason that the color of node.right.right at this time is red, and the color of node.right.left is black. (The node in this row is the node passed in in the delete method) At this time, not Should a left-hand rotation be performed?
I want to understand this problem... This is the code I wrote to simulate the standard implementation. The standard implementation is to first confirm that the element exists in the red-black tree and then delete it; mine is to delete it directly, regardless of whether it exists or not. For the time being. There is no test, but it is basically the same as the standard code implementation
The idea of deletion is similar to the idea of deleting the minimum and maximum values. The previous thinking was limited to how to simulate the deletion of 2-3 trees and did not recognize the relationship between them clearly...
I want to ask the poster a question
In the process of moving to the right branch in delete, the moveRedRight method is called
Excuse me why in the moveRedRight method
node = rotateRight(node);
flipColors(node);
After these two steps are executed Why is there no need to perform left rotation? It stands to reason that the color of node.right.right at this time is red, and the color of node.right.left is black. (The node in this row is the node passed in in the delete method) At this time, not Should a left-hand rotation be performed?