I wonder how we can perform algorithm analysis when in an algorithm we have calls of functions whose definition we do not know, e.g. functions delivered by external libraries.
Asked
Active
Viewed 250 times
3
-
2What do you think? Have you checked our reference question? You do as described there and don't refine what you can't refine; the result is still (somewhat) meaningful. – Raphael Feb 03 '15 at 15:17
1 Answers
7
There are two ways to do this. If you're lucky, the implementer of the external library will have given you a runtime analysis of their code. If you're not, you can use an oracle model of computation. In a sense, this is treating the library routines as if they run in constant time. Of course, that would be ridiculous but an oracle-based analysis is a little smarter than that because it allows you to quantify how many times the oracle is accessed. For example, your answer might end up being something like, "The running time is $O(n^2)$ plus the cost of $O(\log n)$ calls to makeSausage()
on instances of at most linear size."

David Richerby
- 81,689
- 26
- 141
- 235
-
1That is, something like $O(n^2 + \log(n) \cdot T_{\mathtt{makeSausage}}(n))$, assuming
makeSausage
has a non-decreasing, polynomial runtime function. (For super-polynomial runtimes, a constant factor in the parameter would not translate to a constant factor of the result.) – Raphael Feb 03 '15 at 15:18