Answer the question
In order to leave comments, you need to log in
What will be the running time of building a heap?
How long will it take to build a heap if you just add all n elements to the heap sequentially?
Answer the question
In order to leave comments, you need to log in
Most likely the answers are
Ω(nlogn)
O(nlogn)
Since it will take O(n) time to create an empty array and put elements sequentially there, maintaining the properties of the heap (the sifting process) will take O(logn) in the worst case.
But since it is required to select all suitable options, then:
Ω(n) - since the function will grow no slower.
And O(n^2) since the function is limited to n^2 from above.
O(N*log(N)). For each of the last N/2 elements, approximately log(N) operations are needed.
Here it is possible to build a heap by rearranging the elements of an already filled array in O (N) operations.
How long will it take to build a heap if you just add all n elements to the heap sequentially?
I need to select all correct options from the following
O(n)
Ω(n2)
Ω(n)
O(n2)
Ω(nlogn)
O(nlogn)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question