giriraj.prajeet
BAN USER@LOLer
10
/ \
2 15
\ \
4 7
This is a binary tree, whose max-subtree which is a BST is
10
/ \
2 15
\
4
In the above example
10
/ \
2 15
\
4
is not a subtree, since subtree is said to be rooted at some node and everything till leaves are considered. If u say subtree rooted at 10, then that will include all the nodes as its the root of the tree. If we say subtree rooted 2 then that will be as below:
2
\
4
So this example is wrong. But if we take the correct definition of subtree, then we have to go at each node and check if the subtree is BST or not. Amazon asks non sense questions, sometimes they ask some dummy design questions which have no meaning. I attended the interview once then decided that never join such a junk company. I think this question explains why Amazon interviewers are such junk guys with low IQ and knowledge. Basically a company where no one (atleast in India) knows to code in C++ is bound to contain mediocre java programmers and the result is these junk questions.
- giriraj.prajeet December 03, 2013Consider that GET /index.html HTT is sent by some malicious client instead of GET /index.html HTTP/1.0
how will the server should be implemented so that these errors can be taken care.
@LOLer
In the above example
is not a subtree, since subtree is said to be rooted at some node and everything till leaves are considered. If u say subtree rooted at 10, then that will include all the nodes as its the root of the tree. If we say subtree rooted 2 then that will be as below:
So this example is wrong. But if we take the correct definition of subtree, then we have to go at each node and check if the subtree is BST or not. Amazon asks non sense questions, sometimes they ask some dummy design questions which have no meaning. I attended the interview once then decided that never join such a junk company. I think this question explains why Amazon interviewers are such junk guys with low IQ and knowledge. Basically a company where no one (atleast in India) knows to code in C++ is bound to contain mediocre java programmers and the result is these junk questions.
- giriraj.prajeet December 03, 2013