Course Hero Logo

20BCE1545 CSE2011 DSA D1 DA1.docx - Tree is a hierarchical...

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 - 3 out of 11 pages.

Tree is a hierarchical data structure which are defined by a collection of nodes whichrepresent a value. Each node is connected to other nodes by edges. The treeoriginates from a node known as root node which does not have a parent node.Every node in the tree has only one parent node and are connected to its children byedges.RED-BLACK TREE:Red-Black tree is a binary search tree in which each node contains an extra bit whichshows the colour of the node, either red or black. The red and black colour is meantfor balancing the tree at the time of insertion and deletion.Properties of Red-Black Tree:1)Every node in the Red-Black tree is coloured red or black2)The root of the tree is black3)Every leaf node in the tree is black4)The children of every red node are always black5)The path between a node to its descendent leaf has the same black-depthExample of Red-Black Tree:Operations of Red-Black Tree:a)Insertion Operation:In a Red-Black Tree every node being inserted should be of colour red. The insertionoperation in Red-Black Tree is similar to that of Binary Search Tree. The followingsteps should be considered for performing insertion operation of Red-Black Tree:First check whether the tree is empty.
If the tree is empty then insert new node as a black coloured root node andexit from the operation.Insert a red coloured new node as leaf node if the tree is not emptyIf the parent of the new node is black then exit the operation.

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 11 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Spring
Professor
NoProfessor
Tags
collection of nodes

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture