red-black-tree

Difference between red-black trees and AVL trees

…衆ロ難τιáo~ 提交于 2019-11-27 09:10:39
问题 Can someone please explain what the main differences between these two data structures are? I've been trying to find a source online that highlights the differences/similarities, but I haven't found anything too informative. In what cases would one be preferred over the other? What practical situations make one "better" to use than the other? 回答1: AVL trees maintain a more rigid balance than red-black trees. The path from the root to the deepest leaf in an AVL tree is at most ~1.44 lg(n+2),

How to fix remove in RedBlackTree implementation?

爷,独闯天下 提交于 2019-11-27 05:32:41
Here is the implementation of RedBlackTree I am using (from Mark Allen Weiss, Data Structures public class RedBlackTree<AnyKey extends Comparable<? super AnyKey>, AnyValue extends Comparable<? super AnyValue>> implements MyTreeMap<AnyKey, AnyValue>{ private static final int BLACK = 1; private static final int RED = 0; // The psuedo(bogus) root, has a key value of negative infinity and a right link to the real root. private RedBlackNode<AnyKey, AnyValue> header; // Used in place of a null link. Will always be colored black. private RedBlackNode<AnyKey, AnyValue> nullNode; private RedBlackNode

Finding C++ interval tree algorithm implementation [duplicate]

做~自己de王妃 提交于 2019-11-26 20:44:38
问题 This question already has an answer here: C++ - interval tree implementation 5 answers I'm trying to find an efficient C++ interval tree implementation (mostly likely based on red black trees) without a viral or restrictive license. Any pointers to a clean lightweight standalone implementation? For the use case I have in mind, the set of intervals is known at the outset (there would be say a million) and I want to be able to quickly obtain a list of intervals that overlap a given interval.