eyeonu.imtiyaz
BAN USER- 0of 0 votes
AnswersGiven two node values for a tree, find LCA. Consider edge cases - (1) If there exists only one value in the tree, return null. (2) If none of the values exist in the tree, return null. (2) Handle ancestors for duplicate values like -
- eyeonu.imtiyaz in United States
20
/ \
10 50
/ \ / \
10 17 40 60
/ \
5 15
So for above tree if values 5 and 17 are given, there LCA is the upper 10 and not the lower. You can exemplify something I bet :-)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersGiven a sorted array of size n implemented as ring buffer, so that when array has reached (n-1) index, it will be overwritten from 0th index and likewise it will continue. Given any number, find its index in the array in less than linear time. Interviewer asked to consider the edge cases which I could not quite understand during the interview. I told, the edge cases would be no-element array, array with one element and such.
- eyeonu.imtiyaz in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersI will try to state the question. We all know mobile phone's keypad where "2" is mapped to ABC, "3" to DEF and so on. Given any sequence of integers, find all the (matching) combinations in your phone book.
- eyeonu.imtiyaz in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
Answers(screening round)
- eyeonu.imtiyaz in United States
Implement atoi. What would be your approach converting for string to hex.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C
Lets consider for allowing duplicates, 15 is in the right position. (Even the interviewer was stumped when he was creating a tree with duplicates for demonstration)
- eyeonu.imtiyaz November 02, 2012I understand that the 'else if ' is checking for values less than rootnode. No problems. Also, the recursion will terminate if(root.data > value1 && root.data < value2). Again,
if(root.data < value1 && root.data > value2)
10 and 17 are children of 10 and 40 and 60 are children of 50 :-)
- eyeonu.imtiyaz November 01, 2012@ASU
- eyeonu.imtiyaz November 01, 2012@Bin - There is already a thread to handle spaces, negative signs and buffer overflow.
- eyeonu.imtiyaz October 31, 2012
Reppaulaamontalvo, AT&T Customer service email at AMD
I am working as Human Resources Associates, and my duties are for obtaining, recording, and interpreting human resources information within ...
@The Artist - say the array is of fixed size n. When you are done filling the array from 0 to n-1, the next insertion would take place at the zeroth position. For example, you have array like this -
- eyeonu.imtiyaz November 02, 2012Values 1 2 3 4 5 6 7 8 9 10
Array Index 0 1 2 3 4 5 6 7 8 9
Now, if values 11, 12 and 13 are inserted, your array would like like -
Values 11 12 13 4 5 6 7 8 9 10
Array Index 0 1 2 3 4 5 6 7 8 9
That being said, the answer to your first question is yes, the least element can occur at any position. For the question about traversal, I mentioned it that we have to keep it less than n, that is, the linear time. So, traversal should be avoided and as CodeSpace mentioned, binary search is the solution with some modification.