Print path from a node to root of given Complete Binary Tree | Function to print the path from node to root ; Iterate until root is reached ; Print the value of the current node ; Move to parent of the current node ; Driver code
function path_to_root ( node ) { while ( node >= 1 ) { document . write ( node + " " ) ; node = parseInt ( node / 2 , 10 ) ; } } let N = 7 ; path_to_root ( N ) ;