## Amazon Interview Question for SDE-2s

• 0

Country: India

Comment hidden because of low score. Click to expand.
2
of 2 vote

R-trees are tree data structures used for spatial access methods, i.e., for indexing multi-dimensional information such as geographical coordinates, rectangles or polygons.

Comment hidden because of low score. Click to expand.
1
of 1 vote

like below to find the nearest node in binary tree, similar could be done to get the nearest location between to point (x,y) in tree and (x1,y1) the point you are looking from. use some vector algebra.

``````tree* findNearestNumnew(tree* root, int num){
tree* cur = root;
tree* minnode = NULL;
int diff = INT_MAX;
while (cur != NULL){
if (diff > abs(cur->data - num)){
diff = abs(cur->data - num);
minnode = cur;
}
cur = (num < cur->data) ? cur->left : cur->right;
}
return minnode;
}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

R-trees are tree data structures used for spatial access methods, i.e., for indexing multi-dimensional information such as geographical coordinates, rectangles or polygons.

Comment hidden because of low score. Click to expand.
0
of 0 vote

k-d binary tree are the suitable data structure to keep the geographical co-ordinates in k-dimensional plane. where k is 2,3.....n. for k=1 we have generic binary tree data structure.

Comment hidden because of low score. Click to expand.
0
of 0 vote

@praveen.In kd trees we can easily search a particular location(x,y). But could u please explain how to search nearest 10 locations?

Comment hidden because of low score. Click to expand.
0
of 0 vote

@praveen.In kd trees we can easily search a particular location(x,y). But could u please explain how to search nearest 10 locations?

Comment hidden because of low score. Click to expand.
0
of 0 vote

@praveen.
Yes it is easy to search a particular location(x,y) in K-d tree.(say k=2)
But could you please explain how to find nearest 10 locations from a particular location (x,y) ?

Comment hidden because of low score. Click to expand.
-2
of 2 vote

integer, integer and integer. It is the best way to store their location info.

Comment hidden because of low score. Click to expand.

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.