454,948 Members | 1,213 Online
Need help? Post your question and get tips & solutions from a community of 454,948 IT Pros & Developers. It's quick & easy.

# Ternary Heapsort algorithm

 P: 7 i need help to write the code for ternary fix down approach and ternary heapsort can anyone give me link or just give me some help. Nov 6 '08 #1
4 Replies

 Expert Mod 2.5K+ P: 4,677 Sure, what do you need help with? If you post the portion of code you are having trouble with and a description of the issue, I'm sure someone can help. Nov 6 '08 #2

 P: 7 void fixDown3(Item a[], int k, int N) { int j; while (3*k <= N) { c3++; j = 3*k; if (j < N) { if (a[3*k-1]>a[j]) j--; if (a[3*k+1]>a[j]) j++; } if (!(a[k]< a[j])) break; exch(a[k], a[j]); k = j; } }void heapsort3(Item a[], int l, int r) { int k, N = r-l+1; for (k = (N+1)/3; k >=1; k--) fixDown3(&a[0], k, N); while (N > 1) { exch(a[1], a[N]); fixDown3(&a[0], 1, --N); } } This is what i made but i think it s wrong Nov 8 '08 #3

 Expert 100+ P: 671 } This is what i made but i think it s wrong Ok. I wish you luck in fixing your mistakes. Nov 8 '08 #4