Height of Heap Python

PROGRAM TO FIND HEIGHT OF A COMPLETE HEAP



import math
def height(N):
    return math.ceil(math.log2(N + 1)) - 1
 
# driver node
N = 6
print(height(N))


OUTPUT:
2

Comments

Popular posts from this blog

Solve the Sudoku Python

Solve the Sudoku Java

Find Duplicates Java