
Recent Posts
Archives
calendar
July 2018 M T W T F S S « Nov 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Categories
Meta
Tag Cloud
Advertisements
int inorderCheck( TreeNode *root, int *last ) { if( root == NULL ) { *last = INT_MIN; return 1; } int left = inorderCheck( root>left, last ); if( root>data > *last && *last != null ) { *last = root>data; … Continue reading
Here is my code : // Inorder traversal : c b f d g a e (Left, Root, Right)// Preorder traversal : a b c d f g e. (Root, left, right)//// static int rootIdx = 0; public Node … Continue reading
hint : bubble sort would be the most simple in place one
Q1: A binary search tree is given by 2 nodes interchanged, find the 2 nodes. my sol : just inorder traveral the tree, it should be ascending sequence. since there are 2 nodes swapped, scan the sequence, find 2 nodes … Continue reading
serialize, ie, convert the object to a byte stream to transfer it through networking, deseralize, reconstruct the object by give output stream. here is the implementation serialize : public static void serialize( OutputStream out, Node node ){ if( node == … Continue reading
Question 3: There is a N*N integer matrix Arr[N][N]. From the row r and column c, we can go to any of the following three indices: I. Arr[ r+1 ][ c1 ] (valid only if c1>=0) II. Arr[ … Continue reading
amazon set 1 Q1: a sorted array, left rotation r times, find the r in least possible times. sol 1. scan the array, find the min—o(n) sol 2. binary search int findR( int[] arr, int left, int right ) { … Continue reading