0 0 votes Space complexity = input size + extra space So, heap sort also takes input of an 'n' size array. Does this mean that space cost of heap sort algo is O (n). Algorithms space-complexity sorting heap-sort + – Suryakant 1.5k views answer comment Share Follow Print See all 8 Comments 8 8 Comments reply Show 5 previous comments joshi_nitish commented Jul 1, 2017 reply Follow flag we will run heapify from index= floor(n/2) to 1...there is no need of recursion...everything can be done using for and while loops.. 1 1 replyShare Akriti sood commented Jul 1, 2017 reply Follow flag http://www.geeksforgeeks.org/heap-sort/ pls see the code for heapify()here. 0 0 replyShare joshi_nitish commented Jul 1, 2017 reply Follow flag heapify can be performed by both iterative and recursive way...but the best among two is iterartive since it give less space complexity(O(1)) then reccursive (O(logn))... 1 1 replyShare Please log in or register to add a comment.
0 0 votes Space complexity in heap sort will be height of the stack and for n number of nodes in complete or almost complete binary tree height would be logn so space complexity should be O(logn) Mohitkumaraiactr answered Jul 1, 2017 Mohitkumaraiactr comment Share Follow 0 reply Please log in or register to add a comment.