edited by
4,779 views
0 votes
0 votes

Since Heapify is a recursive function, its space complexity is $O(logn)$ because of the stack space required for recursion.
I also read that space complexity of heapsort is $O(1)$ beause of the explanation here - https://gateoverflow.in/79909/space-complexity-of-heap-sort .

So my question is why the space complexity of Build Heap is $O(logn)$ ?

If space complexity of build heap is $O(logn)$ then heapsorts complexity should also be the same . What am I missing here ?

edited by

1 Answer

0 votes
0 votes
Heapify function can be implemented in recursive as well as iterative way, so if we implement heapify function in iterative way I think space complexity will be O(1)

Related questions

9 votes
9 votes
2 answers
1
vineet.ildm asked Nov 7, 2016
5,938 views
Why space complexity of heapsort is O(1)....and why not O(logn)..because of space required by recursion calls which is equivalent to height of the tree...where am i getti...
0 votes
0 votes
1 answer
3
syedasafoora asked Nov 8, 2023
251 views
Consider the following algorithm for Build-Max-heap and the given array A=[ 47,96, 35, 54, 77, 65, 83]. Run this algorithm on the given array and redraw the heap and the ...
1 votes
1 votes
1 answer
4
LavTheRawkstar asked Sep 9, 2018
1,068 views
Sort The Following Sequence of input using Heap sort.{ 10 , 2 , 1 , 5, 3 ,8 ,11,24 ,7 }Please show the output at every pass because i am getting confused.