Check if an array represents Inorder of Binary Search tree or not | Function that returns true if array is Inorder traversal of any Binary Search Tree or not . ; Array has one or no element ; Unsorted pair found ; No unsorted pair found ; Drivers code
function isInorder ( arr , n ) { if ( n == 0 n == 1 ) { return true ; } for ( i = 1 ; i < n ; i ++ ) { if ( arr [ i - 1 ] > arr [ i ] ) { return false ; } } return true ; } var arr = [ 19 , 23 , 25 , 30 , 45 ] ; var n = arr . length ; if ( isInorder ( arr , n ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }