akshay.shetye
BAN USER- 0of 0 votes
AnswersWrite a code to find out endness of a system?
- akshay.shetye in India
(I am a java guy).How can we do it in java?Do we need to take care of endness in java?If yes give exmaples of such situation?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm
hi, i corrected my ans and i think it should work fine now
- akshay.shetye November 20, 2011nice one!
- akshay.shetye November 20, 2011int sumify(Node node){
if(node == null)
return 0;
else{
int tmp = node.data;
node.data = sumify(node.left)+sumify(node+right);
return node.data+tmp; //corrected this
}
}
Node reverse(Node head,Node previous){
if(head == null)
return previous;
Node tmp = head.next;
head.next = previous;
prevoous = head;
reverse(tmp,previous);
}
Great solution .Its time complexity is O(n)too.
- akshay.shetye July 30, 2011@ALL: Trie can be useful to search a phonenumber when name is given.What if i want to find a persons name given his phone number. i.e how can i find name when i know the phone number?Is trie efficient for such search?
- akshay.shetye July 30, 2011
@kartik:We cannot use inbuild methods,We need to write a algo/code to detect it :)
- akshay.shetye December 04, 2011