Doubt for heap Sort Implimentation

This is the code which was written but for
5 elements it did not work

at line no 33

instead of curr_idx it must be min_idx

also your build function is wrong
correct one
image

Modified Code

Could you please explain as to why at line number 33 have we used min_idx ?

Suppose root->data is 3
Left 1 and right data is 2
Then in that case your code consider 2 as min
But actually 1 is min
Because you are checking with root not with min so far

This is simple calculation of min among 3