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 ? Algorithms space-complexity algorithms binary-heap heap-sort + – Hardik Maheshwari asked Jun 14, 2018 • edited Jun 26, 2019 by Cristine Hardik Maheshwari 4.8k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
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) rajatmyname answered Feb 7, 2019 rajatmyname comment Share Follow See all 0 reply Please log in or register to add a comment.