Sunday , December 11 2016
Home / C / c program for implementing Heap sort in C Language

c program for implementing Heap sort in C Language

This program is for Heap Sort in C.

Incoming terms: Program for implementing heap sort in c, heap sort program in c

Also See:   Program for Shortest Job First (SJF) scheduling technique

Check Also

Hide Mouse Pointer C Program

How to Hide a Mouse Pointer Program in C : This program will show and hide ...

3 comments

  1. Enter the size of array : 6
    Enter the elements of array
    3 6 7 8 1 4
    sorted array is
    1 7 3 4 6 8

    The code seems to be messing up , please correct it

  2. correct the max heap function to:

    void maxheap(int a[],int i,int n)
    {
    int R,L,largest,t;
    L=2*i;

    R=2*i+1;
    if((La[i]))
    largest=L;
    else
    largest=i;
    if((Ra[largest]))
    largest=R;
    if(largest!=i)
    {
    t=a[i];
    a[i]=a[largest];
    a[largest]=t;
    maxheap(a,largest,n);
    }
    }

    • void maxheap(int a[],int i,int n)
      {
      int R,L,largest,t;
      L=2*i;

      R=2*i+1;
      if((La[i]))
      largest=L;
      else
      largest=i;
      if((Ra[largest]))
      largest=R;
      if(largest!=i)
      {
      t=a[i];
      a[i]=a[largest];
      a[largest]=t;
      maxheap(a,largest,n);
      }
      }

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.