Please find and share algorithm about red/black trees. Explain it, give 2 real world usages and discuss its efficiency with your friends!
Please don't copy my previous question:)
Sol:
Algorithm
Step 1: Let the initial tree be: initial tree
Step 2: if m has a left subtree,assign n as the parent of the left subtree of m.
Step 3: if the parent of n is null, make m as the root of the tree.
Step 4: Else if n is the left child of p, make m as the left child of p.
Step 5: make m as the parent of n
Real world usage of red black trees
- They are used in the Linux kernel.for example in a process scheduler or for keeping a track of the virtual memory segment for a process.
- also used in maps,multimap etc.
Get Answers For Free
Most questions answered within 1 hours.