Hello

Code:
Code:
#include "stdio.h" 
#include "conio.h" 
void heap(int a[], int, int n); 
void sort(int a[], int n); 
int main() 
{ 
const int n = 8; 
int a<img src="/emoticons/emotion-45.gif" alt="No [N]" /> = {88, 66, 77, 33, 55, 44, 22, 99}; 
int i; 
clrscr(); 
sort(a, n); 
for(i = 0; i ); 
getch(); 
return 0; 
} 
//*************** 
void sort(int a[], int n) 
{ 
int i, t; 
for(i = n/2 - 1; i >= 0; i--) 
heap(a, i, n); 
for(i = n - 1; i > 0; i--) 
{ 
t = a[0]; 
a[0] = a<img src="/emoticons/emotion-55.gif" alt="Idea [I]" />; 
a<img src="/emoticons/emotion-55.gif" alt="Idea [I]" /> = t; 
heap(a, 0, i); 
} 
} 
//*************** 
void heap(int a[], int k, int n) 
{ 
int t, j; 
t = a[k]; 
while(k a[j]) 
break; 
a[k] = a[j]; 
k = j; 
} 
a[k] = t; 
}


It is said:

In array ,Leaves are saved in a<img src="/emoticons/emotion-45.gif" alt="No [N]" />..a[n/2],Why?


And it is said:

So first loop in sort () ,runs on a[0] ...a[n/2-1].Why?


May someoen explain about the second loop?

Thanks in advance