Question

In: Computer Science

Find and share an algorithm about red/black trees. Explain it, give 2 real-world usages, and discuss...

Find and share an algorithm about red/black trees. Explain it, give 2 real-world usages, and discuss its efficiency.

Solutions

Expert Solution

red/black tree

A red-black tree is a binary search tree with one extra attribute for each node: the colour, which is either red or black. We also need to keep track of the parent of each node, so that a red-black tree's node structure would be:

struct t_red_black_node {
enum { red, black } colour;
void *item;
struct t_red_black_node *left,
*right,
*parent;
}

A red-black tree is a binary search tree which has the following red-black properties:
1.Every node is either red or black.
2.Every leaf (NULL) is black.
3.If a node is red, then both its children are black.
4.Every simple path from a node to a descendant leaf contains the same number of black nodes.

give 2 real-world usages

1. They are common in the Linux kernel. For example in a process scheduler or for keeping track of the virtual memory segments for a process

2.They are also used in map, multimap, multiset from C++ STL and java.


Related Solutions

Please find and share algorithm about red/black trees. Explain it, give 2 real world usages and...
Please find and share algorithm about red/black trees. Explain it, give 2 real world usages and discuss its efficiency with your friends!
The insertions in red-black trees cost upto 2 rotations (if uncle is black) and upto O(log...
The insertions in red-black trees cost upto 2 rotations (if uncle is black) and upto O(log n) color changes (if uncle is red). Show that amortized color updates per insertion is O(1). (Hint: to develop an appropriate potential function try to see what is decreasing in the structure when we push the red-conflict upwards in case 1.)
In about 150 words, discuss the challenging goals and give example from the real business world.
In about 150 words, discuss the challenging goals and give example from the real business world.
In about 150 words, discuss the conflicting goals and give example from the real business world.
In about 150 words, discuss the conflicting goals and give example from the real business world.
In about 150 words, discuss the compatible goals and give example from the real business world.
In about 150 words, discuss the compatible goals and give example from the real business world.
In about 150 words, discuss the compatible goals and give example from the real business world.
In about 150 words, discuss the compatible goals and give example from the real business world.
Please explain each answer Problems Red-Black Trees (a) Given that we follow the insertion operations; What...
Please explain each answer Problems Red-Black Trees (a) Given that we follow the insertion operations; What is the largest possible number of red nodes in a red-black tree of n nodes? What is the smallest possible number? (b) Can a black node have one red child and one black child ? If we relax the condition such that the children of a red node can be either red or black, what are operations necessary to keep the tree balanced ?...
Please find and share one sorting/searching algorithm. Explain it, and discuss its efficiency with your friends!
Please find and share one sorting/searching algorithm. Explain it, and discuss its efficiency with your friends!
Plese explain all in mircrosoft word Define, discuss, and give a real world example that demonstrates...
Plese explain all in mircrosoft word Define, discuss, and give a real world example that demonstrates the relationship between Adam Smith’s Invisible Hand Theory and Perfect Competition.
How would I go about this question? Discuss, and give real world examples of how scarcity,...
How would I go about this question? Discuss, and give real world examples of how scarcity, decision making, and opportunity cost relate.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT