Johnybegood
BAN USER- 1of 1 vote
AnswersImage an airport with the control tower having a constantly rotating radar scanning for airplanes. The radar's coordinates in the 2-d plane are (0,0). The radar has an API: void scan(const Plane &P) that is called periodically whenever the radar detects a plane. You can imagine that the Plane structure has x,y coordinates for that plane. You should fill in the function Scan, such that at any given time you are able to return the 100 closest planes to the tower (0,0).
- Johnybegood in United States for Derivatives| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Algorithm - 0of 0 votes
Answerswrite a program to parse a prefix expression and calculate it's result. Example: *-6 5 7 = 7.
- Johnybegood in United States| Report Duplicate | Flag | PURGE
Qumulo Member Technical Staff Algorithm - 0of 0 votes
AnswersYou're given a maze (that is not necessarily square shaped). The maze is composed of square rooms. In one of these rooms there is a flag. You have a robot that you can control using the following APIs:
- Johnybegood in United States
1. void Go() - drives the robot straight.
2. void Turn(int degrees) - turns the robot x degrees to the right (x has to be a multiple of 90).
3. bool IsWall() - returns true if the robot is facing a wall (you can't move from one room to the other).
4. bool IsFlag - returns true if the room has the flag in it.
5. void PutBreadCrumb() - throws a single breadcrumb in the room.
6. bool HasBreadCrumb()- returns true if the room contains a breadcrumb.
Using these Apis only, write a program to navigate the robot through the maze until it finds the flag.| Report Duplicate | Flag | PURGE
Qumulo Member Technical Staff Algorithm
There scan API is correct. You can view it as an interrupt service routine that is called periodically. You should have separate data structures that will hold the relevant information so that when a query comes, you can return the right information (e.g. the closest 100 planes). you should obviously modify these data structures in the Scan routine. Also, as a follow up make sure you handle correctly the fact that the same plane might be spotted multiple times - How would you change your DS to handle this scenario ? Next follow up - clean up of your data structure. When do you know it is OK to remove an airplane from your DS ? I'll submit an answer to this question later on.
- Johnybegood December 24, 2015