Course Hero Logo

paper.docx - Red and Black trees Abstract: This paper deals...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 5 out of 13 pages.

Red and Black treesAbstract:This paper deals with the concepts of red-black trees, which is one of the binary search tree. Each node ofthe binary tree has an extra bit, and that bit is often interpreted as the color (red or black) of the node.These color bits are used to ensure the tree remains approximately balanced during insertions anddeletions.From this paper I want to explain the behavior and properties of the red black trees by coming upwith problem statements in this method and their solutions.1
Table of Contents:ļ‚·Introductionļ‚·Propertiesļ‚·Insertionļ‚·Top down Red-Black treesļ‚·Examplesļ‚·Applicationsļ‚·Time Complexity2
ļ‚·ConclusionIntroduction:A red–black tree is a special type of binary tree, used in computer science to organize pieces of comparabledata, such as text fragments or numbers. The leaf nodes of red–black trees do not contain data. Theseleaves need not be explicit in computer memory—a null child pointer can encode the fact that this child isa leaf—but it simplifies some algorithms for operating on red–black trees if the leaves really are explicitnodes. To save memory, sometimes a single sentinel node performs the role of all leaf nodes; all referencesfrom internal nodes to leaf nodes then point to the sentinel node. Red–black trees, like all binary searchtrees, allow efficient in-order traversal (that is: in the order Left–Root–Right) of their elements. The search-time results from the traversal from root to leaf, and therefore a balanced tree of n nodes, having the leastpossible tree height, results in O(log n) search time. In an AVL tree, we recourse down the tree to find theinsertion (removal) location, then work back up the tree to update the heights and rebalance the tree. In ared-black tree, a single pass down the tree will take care of business. An iterative solution is used.Properties:3
Ared-black treeis a binary search tree with the following properties:1.Every node is either red or black2.Root node is black3.All nodes are black4.The children of any red node are black5.Every path from a node to a null link must contain the same number of black nodesThese constraints enforce a critical property of red–black trees: the path from the root to the farthest leafis no more than twice as long as the path from the root to the nearest leaf. The result is that the tree isroughly height-balanced. Since operations such as inserting, deleting, and finding values require worst-casetime proportional to the height of the tree, this theoretical upper bound on the height allows red–blacktrees to be efficient in the worst case, unlike ordinary binary search trees.To see why this is guaranteed, it suffices to consider the effect of properties 4 and 5 together. For a red–black tree T, let B be the number of black nodes in property 5. Let the shortest possible path from the rootof T to any leaf consist of B black nodes. Longer possible paths may be constructed by inserting red nodes.

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 13 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
Test, ISBN, Red black tree, Self balancing binary search tree, concepts of red black trees

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture