Given a forest represented as an array where each element stores its parent node's index (0-based). Root nodes are self-referential: parent[i] == i. There are no NULL or None values; the input is always valid. Write a function to delete a specified node from the forest…