Number of edges in a perfect binary tree with N levels | Java implementation of the approach ; Function to return the count of edges in an n - level perfect binary tree ; Driver code
class GFG { static int cntEdges ( int n ) { int edges = ( int ) Math . pow ( 2 , n ) - 2 ; return edges ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . println ( cntEdges ( n ) ) ; } }