Question: An easter algorithm problem Easter is just around the corner, so it's better to start preparing. The Easter Bunny has buried Easter eggs at $n$

An easter algorithm problem
Easter is just around the corner, so it's better to start preparing. The Easter Bunny has buried Easter eggs at $n$ locations $(x_i, y_i)$, $i =1,..., n$. Each Easter egg has a taste quality $b_i$ that depends on what is put in the Easter egg and can be positive or negative. All Easter eggs we pick up must be eaten, and we want to maximize the sum of $b_i$. Since we have limited time, we borrow a digger that can take all Easter eggs in some area bounded by $x', y'$, ie. we get all eggs with coordinates $x_i \leq x'$, $y_i \leq y'$.
Argue that the best area to dig up $x', y'$ can be chosen such that the coordinates $x$ and $y$ are one of the coordinates of the Easter eggs (not necessarily of the same egg).
We add one function to an AVL tree, T. For $k$ we define
$$
\text{prefix\_val}(k)=\sum_{x.key \leq k} x.val
$$
where the sum is taken over all keys in $T$. We want to find the node $y$ that maximizes prefix\_val($y.key$). Show how to modify AVL trees to find this node and the prefix\_val value in $O(1)$ time.
Describe how to use this data grid (along with other methods) to find the best coordinate to unearth the Easter eggs in $O(n\log n)$ time.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!