|Related to : Heap Sort Space Complexity|
|Why does a dynamically linked executable on Linux have the complete memory space of libc in its own memory space?|
Why does the system map the whole libc and ld shared objects into
the process' memory range? I thought there would only be a pointer to
the libc which is loaded in memory only once systemwide?
It does map it once systemwide, then it maps those pages into each
process' virtual memory address space. Those pages are shared by every
process (at least the read-only parts)
You can't just hav
|Complexity of a basic algorithm?|
When determining complexities, we don't include constants or
coefficients. Instead of O(2N + 2), it should be O(n). We only care
about numbers if they're exponential, i.e. 2^n or n^2, log2(n), etc.
Putting that aside, are you sure this is O(n)? O(n) would mean that it
runs n times, but it looks like j is going to catch up to n before n
times. See what I'm saying?
EDIT: Ok, here's what's going o
|What's the order of complexity (Big O) of this code|
The inner loop is O(N^2) for prime numbers but fast for non-primes
(worst case O(N^1/2) because you only have to search up to sqrt(N)).
The number of prime numbers, however, is small compared to the number
of non-primes. An approximation of the number of primes to up X is:
X / log(X), as found in this reference link.
So throwing out the non-primes as inconsequential, there are N /
|Complexity of enum.values()|
The array returned by Colour.values() always contains the same
elements, but values() creates a new array every time it's called (so
it's O(n) where n is the number of enum values). And you never modify
that array. So calling the method every time you need it is a waste of
time. And storing an array in every instance of your DataStructure
class is a waste of time and memory. I would simply call th
|SPARQL Query Computational Complexity|
SPARQL itself is PSPACE-complete. You can probably only come up with
the best case complexity for any given query. The real-world
complexity will depend on the implementation of the database to some