especially advantageous by ingly digital. Digital cartography is letting users s
ID: 3825857 • Letter: E
Question
especially advantageous by ingly digital. Digital cartography is letting users select the size and color of "event radii" les showing the area effected by some This ability, in turn, i enabled by data enable efficient searching-binary search structures which not only order data, but can trees. Onthis question, you will answering questions about using binary search trees to MapLoc instances, where MapLoc is a class used to represent a single location on a map. is: public class MapLoc private double K: Location on the map's horizontal axis Private doubly y: Location on the map's vertical axis Public Mal (double nx, double nr) x nx i y nY: Public double diatance (MapLoc aourc.) source. 2)) return Math.sqrt CMath -pov Cx source 2) Math. Pov cy .y. A) 10 pointsl Because MapLoc instances are NOT comparable, our binary search tree will need to use a Compar ator Diatcomp compare two Map using their distance from origin (the location where an event occurred Complete the Dietcomp class so that it performs this comparison. public class Dist comp implements comparator private MapLoc origin eli public Dist conp (Maploe el) origin t a rare da ble "if m is deser to orkeim return return turn 0.Explanation / Answer
I have given code for part C and part D :-
FOR PROBLEM C
public Maploc closest()
{
int close;
close=compare(m1,m2);
if(close==-1)
{
//m2 is closest
}
if(close==1)
{
//m1 is closest
}
if(close==0)
{
//both are at equal distance
}
}
FOR PROBLEM D
public int numInRadius(double maxDist)
{
return numInRadius(root,maxDist);
}
private int numInRadius(BTNode node,double maxDist)
{
if(inRad(maxDist))
{
if (node == null) return 0;
int left = numInRadius(node.left,maxDist);
int right =numInRadius(node.right,maxDist);
return left + right + 1;
}
}
Please let me know in case clarification is required.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.