Aseem Vyas
BAN USERHow it will work ???? The list is unsorted. x XOR n where x can be any thing from 1-1000, may be i am missing something. Please Expain.
- Aseem Vyas January 16, 2012Agreed :(
- Aseem Vyas January 16, 2012Sum the every thing and subtract it from the sum for first billion+1 integers , you have your missing number.
- Aseem Vyas January 15, 2012You can add some more info the the traversal, like in the actual list from inorder traversal add info containing the path it took for the traversal (15R16PP17R19L18PR20). This can also be modified for any other tree.
I any case i agree that comparing tree traversals will be better than comparing trees directly as we can not directly guess where (if) the sub tree will fit into the main tree.
Again* , we are (actually I am) assuming nodes implement some ToString() method. Trees with complex nodes will create issues as to store/compare traversals might not be viable.
One more thing to add to this, what about the endian-ness of the system , i mean how will you now that an ip address will convert to 192.168.1.2 or 2.1.168.192
We use ntohl() and htonl(), these are ought to be used.
I think its thats what vijay is doing, but he is he is also eliminating smaller elements at the same time. for smaller k , nlog(k) can be much lesser than nlog(n)
- Aseem Vyas January 15, 2012And its asked by Microsoft :D
- Aseem Vyas January 14, 2012One way that i think is much faster is to
1: copy the content of the file in memory (or another file). (We will call this 'data')
2: Get the first word and search it in the data.
3: Count how many times the word occurred and rewrite the memory where each occurrence occurred with white spaces.
4: Do same for the next word.
Rewriting the momory will ensure that we will not scan the same word twice. Also that if we user Boyer-Moore for string search then these overwritten whitespace chunks will be skipped in long jumps( so you will get a nice performance boost after first few words)
At the end of each 'for' block there is a comparison operation to check weather to continue or not. For the inner 'for' loop this check is always row*column times but we can save this for the outer 'for' loop. Hence func1() is better.
- Aseem Vyas January 19, 2012