Tree Transformation | Hindi | GFG POTD | C++ | Java | Code Kar Lo



Tree Transformation | Hindi | GFG POTD | C++ | Java | Code Kar Lo

Tree Transformation | Hindi | GFG POTD | C++ | Java | Code Kar Lo

You are given a tree containing N nodes in the form of an array P where Pi represents the parent of the i-th node and P0 = -1 as the tree is rooted at node 0. In one move, you can merge any two adjacent nodes. Calculate the minimum number of moves required to turn the tree into a star tree.

– Merging adjacent nodes means deleting the edge between them and considering both the nodes as a single one.
– A Star tree is a tree with a center node, and all other nodes are connected to the center node only.

0:00 Introduction
0:14 Problem Statement
1:54 White Board Explanation
9:39 Complexity Analysis
9:54 C++ Code
11:08 Java Code

My DSA Journey:- https://youtu.be/quZBBv12mCQ

How to Earn By GFG Articles:- https://youtu.be/XjvEgkd49Gk

Problem Link:-https://practice.geeksforgeeks.org/problems/fbcd1787378ed396a8f24b47872cbc0ad2624f1d/1

Code Link:-https://github.com/ShubhamKashyap138/Data-Structure/blob/main/Tree%20Transformation

Playlist Link:-https://youtube.com/playlist?list=PLq3GlRZI14Hui2ILGsfF1Uf2RnbNu9wT3

Linkedin:- https://www.linkedin.com/in/shubham-kashyap-65a29a218/

Instagram:- https://instagram.com/im_shubham_kashyap?igshid=YmMyMTA2M2Y=

My GFG Profile:- https://auth.geeksforgeeks.org/user/shubhamrajput6156/practice

gfg potd
gfg potd today
gfg problem of the day
potd gfg
potd
potd today
gfg

#dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming

Comments are closed.