5 5 votes During heap sort, the array looks like this:$J = [7, 3, 6, 2, 1, 4, 5, 8, 9]$Assume heap sort is using a max-heap to sort the array in increasing order.How many elements are still in the heap? Data Structures goclasses goclasses-da-dpp goclasses-da-dpp-day-230 goclasses-cs-dpp goclasses-cs-dpp-day-328 data-structures python-&-dsa goclasses-python-&-dsa-practice-questions goclasses-ds-practice-questions max-heap heap-sort numerical-answers + – GO Classes 230 views answer comment Share Follow Print See 1 comment 1 1 comment reply One_Last_Hope commented Aug 19 reply Follow flag Question is not completed guys how many elements still in heap not sorted order 1 1 replyShare Please log in or register to add a comment.
1 1 vote In heap sort using a max-heap, the array is divided into two parts:The left part is the active heap. The right part is the sorted region.The largest elements move to the end of the array one by one.Here, the last two elements are:$8, 9$They are already in sorted order and are no longer part of the heap.Now check the remaining left part:$[7, 3, 6, 2, 1, 4, 5]$This is a valid max-heap:$7 \geq 3$ and $7 \geq 6$ $3 \geq 2$ and $3 \geq 1$ $6 \geq 4$ and $6 \geq 5$ So, the active heap has $7$ elements.Answer: $\boxed{7}$ GO Classes answered Jul 21 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.