I have an algorithm that runs in O(m) time. This algorithm takes in a set of data containing m entries.
The data is generated randomly by specifying a strictly positive integer input n. The number of entries generated is O(n log n).
Edit
Alone, the time complexity of generating the data is independent of n (or O(1)), which means given the integer n, the entries are instantly and randomly generated. The number of resulting entries is random, but is O(n log n). E.g. n = 10, then number of entries generated is some constant times 10 (log 10).
The data is generate before hand. Then the resulting m entries is fed into the algorithms as input.
Question
Can I then assume that the algorithm runs in O(n log n) time?
There are some ambiguities in your question that were either deliberately place to help you internalize the relationship between input size and run time complexity, or simple caused by miscommunication.
So as best as I can interpret this scenario:
Your algorithm complexity
O(m)is linear with respect to m.So since
We assume that generating the data is independent of input. i.e. O(1)., your time-complexity is only dependent on somenthat you specify that generates entries.So yes, you can say that the algorithm runs in
O(n log n)time, since it doesn’t do anything with the input of sizem.In response to your updated question:
It’s still hard to follow because some key words refer to different things. But in general I think this is what you are getting at:
To see the difference: Suppose your algorithm wasn’t linear but rather quadratic O(m^2), then it would have time-complexity O(n^2 log^2 n) with respect to n.