How to do an inverted heap implementation in JAVA?

What is wrong with this Heap Sort implementation in C?

  • Hi! I have been trying to find error in this implementation of Heap sort algorithm in C but am unable to find it. It is compiling fine but when I execute the program it gives an ...show more

  • Answer:

    You can understand better by the following example... int main() { int arr[20]; int i,j,size,tmp,k; printf("\n\t------- Heap sorting method -------\n\n"); printf("Enter the number of elements to sort : "); scanf("%d",&size); for(i=1; i<=size; i++) { printf("Enter %d element : ",i); scanf("%d",&arr[i]); manage(arr,i); } j=size; for(i=1; i<=j; i++) { tmp=arr[1]; arr[1]=arr[size]; arr[size]=tmp; size--; heapsort(arr,1,size); } printf("\n\t------- Heap sorted elements -------\n\n"); size=j; for(i=1; i<=size; i++) printf("%d ",arr[i]); getch(); return 0; }

7DGTYURNMYMLCIX66E5HO47F3U at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.