A tree , is an object that consists of some locations and some connections. the locations arecalled vertices and the connections between vertices are called edges. Each edge connectssome pair of vertices. The number of vertices is always one greater than the number of edges.The entire tree is connected: the edges connect the vertices in such a way that one can walkfrom any verstex to any other verstex by following a sequence of edges.You are given the description of a tree with n+1 verities and n edges: a int[] tree with nelements. The vertices of our tree are numbered 0 through n. for each i between 0 and n -1.inclusive. there is an edge between vertices i+1 and tree[i]. (The constraints guarantee thatthese edges always form a valid tree.)You are now going to destroy the tree by removing one of its vertices (and all edges that gofrom that vertex to some other vertex). When you do so, the tree may sometimes fall apartthere will be more than one connected component.Compute and return the largest number of components you can get by removing a single,vertex of your tree.
đang được dịch, vui lòng đợi..
