Question: Suppose you are building a first-person shooter game, where virtual zombies are climbing up a wall while the player, who is moving left and right
Suppose you are building a first-person shooter game, where virtual zombies are climbing up a wall while the player, who is moving left and right in front of the wall, is trying to knock them down using various weapons. The position of each zombie is represented with a pair, (x, y), where x is the horizontal position of the zombie and y is its height on the wall. The player’s position is specified with just a horizontal value, xp. One of the weapons that a player can use is a bomb, which kills the zombie that is highest on the wall from all those zombies within a given horizontal distance, r, of xp. Suppose the zombies are stored in a binary search tree, T, of height h, ordered in terms of their horizontal positions. Describe a method for augmenting T so as to answer maximum-zombie queries in O(h) time, where such a query is given by a range [xp−r, xp+r] and you need to return the coordinates of the zombie with maximum y-value whose horizontal position, x, is in this range. Describe the operations that must be done for inserting and deleting zombies as well as performing maximum-zombie queries.
Step by Step Solution
3.50 Rating (160 Votes )
There are 3 Steps involved in it
We can augment the binary search tree T with an additional field to each node ... View full answer
Get step-by-step solutions from verified subject matter experts
