please help me to solve problem
- by davit-datuashvili
i have operation on heap fixdown operation below is code
public class HEap{
public static void fixdown(int a[],int k,int n){
while(2*k<=n){
int j=2*k;
if (j<n && a[j]<a[j+1]) j++;
if (!(a[k]<a[j])) break;
int t=a[k];
a[k]=a[j];
a[j]=k;
k=j;
}
}
public static void main(String[]args){
int a[]=new int[]{12,15,20,29,23,22,17,40,26,35,19,51};
fixdown(a,1,a.length);
for (int i=0;i<a.length;i++){
System.out.println(a[i]);
}
}
}
//and result is
12
29
20
40
23
22
17
3
26
35
19
51
i am interested why is 3 in the list?in the array is not