Sorted order printing of a given array that represents a BST | Javascript Code for Sorted order printing of a given array that represents a BST ; Print var left subtree ; Print var root ; Print var right subtree ; Driver code
function printSorted ( arr , start , end ) { if ( start > end ) return ; printSorted ( arr , start * 2 + 1 , end ) ; document . write ( arr [ start ] + " " ) ; printSorted ( arr , start * 2 + 2 , end ) ; } var arr = [ 4 , 2 , 5 , 1 , 3 ] ; printSorted ( arr , 0 , arr . length - 1 ) ;