Module 2
Trees
Remove Child


CC315

Image Credit: FreeSVG

MyTree parent children item
a none {b,c} A
b a {d} B
c a {x} C
d b {} D
x c {y,z} X
y x {} Y
z x {} Z
MyTree parent children item
a none {b,c} A
b a {d} B
c a {} C
d b {} D
x none {y,z} X
y x {} Y
z x {} Z

Special Considerations

  • Node should be child of parent

Pseudocode


function REMOVECHILD(CHILD)
    IF CHILD in PARENT`S children
        REMOVE CHILD from PARENT`s children
        SET CHILD`s PARENT to NONE
        return TRUE
    ELSE
        return FALSE
end function