What is the below pseudo code trying to do, where pt is a node pointer and root pointer?
Posted: Wed Jul 13, 2022 7:42 pm
redblack(Node root, Node pt) :
if (root == NULL)
return pt
if (pt.data < root.data)
{
root.left = redblack(root.left, pt);
root.left.parent = root
}
else if (pt.data > root.data)
{
root.right = redblackt(root.right, pt)
root.right.parent = root
}
return root
a) insert a new node
b) delete a node
c) search a node
d) count the number of nodes
if (root == NULL)
return pt
if (pt.data < root.data)
{
root.left = redblack(root.left, pt);
root.left.parent = root
}
else if (pt.data > root.data)
{
root.right = redblackt(root.right, pt)
root.right.parent = root
}
return root
a) insert a new node
b) delete a node
c) search a node
d) count the number of nodes