- #1
NATURE.M
- 301
- 0
Homework Statement
We have four integers a,b,c,d each of which are >= 1 and <= n, and are asked to write an algorithm to find all possible solutions to the following equation: a7 + b7 = c7 + d 7
The algorithm should use a heap of at most n elements, and should have worst case runtime of O(n2 log n).
The Attempt at a Solution
Some basic math will tell us that there are n4 possible combinations of a,b,c,d for some input n. So if we go through each possible combination it would be very costly. This is where the heap is suppose to come into play. But I'm having particular difficulty determining how we would actually use it for this question.