If you move the max element to the back of your heap array and then delete it, you're not going to be left with anything in your array when completes. So, your algorithm, which deletes the max, is not going to result in a sorted array of your original elements.
Update based on OP edit:
You can do it that way. The first method, though, allows you to sort in place. Your method requires O(N) additional storage.
Another Edit:
It's difficult to see exactly what assumptions you're making on the first algorithm, but as I think about the comment I made below, it seems likely that MaxHeapify(A,1)
should probably be MaxHeapify(A, n)
. You will usually pass an array and its size, or in this case, the number of elements you want to arrange as a heap. This might be moot if you are assuming that n is a global variable.