Monday, 23 March 2009

deque better than vector?

MSVC is more STL-friendly now. It can help us resolve questions like, is deque better than vector?

C++ strongman Herb Sutter helps us find the answer.

Ever wonder how associative containers like maps are implemented? The standard implementation is to use a self-balancing binary search tree, such as Sedgewick's red-black trees. Red-black trees are trees where each node is either red or black and the root node is black (in most definitions). The tree has the property of being "roughly balanced" - formerly defined this says that

longest path(RL) <= 2*shortest_path(RL)

(<= reads "less than or equal to" or "cannot exceed", RL == root_to_leaf). in that tree.

Tree traversals are important in computer science (preorder, inorder, postorder). These should be known forwards, backwards and back-to-front.

No comments: