#2746
Heap Sort
Se dă n
și un sir cu n
elemente, numere naturale. Folosind metoda HeapSort
, să se sorteze crescător șirul și să se afișeze elementele sale, separate prin câte un spațiu.
Problema | Heap Sort | Operații I/O |
![]() heap_sort.in /heap_sort.out
|
---|---|---|---|
Limita timp | 0.45 secunde | Limita memorie |
Total: 64 MB
/
Stivă 64 MB
|
Id soluție | #51447974 | Utilizator | |
Fișier | heap_sort.cpp | Dimensiune | 1.84 KB |
Data încărcării | 18 Iunie 2024, 11:14 | Scor / rezultat | Eroare de compilare |
heap_sort.cpp:8:1: error: expected ',' or ';' before 'const' const int NMAX = 1e5; ^ heap_sort.cpp:9:7: error: 'NMAX' was not declared in this scope int H[NMAX + 1]; ^ heap_sort.cpp: In function 'void HeapUp(int)': heap_sort.cpp:24:20: error: 'H' was not declared in this scope while(K > 1 && H[K] < H[father(K)]) { ^ heap_sort.cpp: In function 'void HeapDown(int, int)': heap_sort.cpp:35:37: error: 'H' was not declared in this scope if(right_son(K) <= N && H[right_son(K)] < H[son]) { ^ heap_sort.cpp:39:19: error: 'H' was not declared in this scope if(son && H[son] < H[K]) { ^ heap_sort.cpp: In function 'void insert(int&, int)': heap_sort.cpp:49:5: error: 'H' was not declared in this scope H[++N] = value; ^ heap_sort.cpp: In function 'int find_min()': heap_sort.cpp:54:12: error: 'H' was not declared in this scope return H[1]; ^ heap_sort.cpp: In function 'void extract_min(int&)': heap_sort.cpp:58:10: error: 'H' was not declared in this scope swap(H[1], H[N]); ^ heap_sort.cpp: In function 'void Delete(int&, int)': heap_sort.cpp:70:10: error: 'H' was not declared in this scope swap(H[K], H[N]); ^ heap_sort.cpp: In function 'void decrease_key(int, int)': heap_sort.cpp:80:5: error: 'H' was not declared in this scope H[K] -= value; ^ heap_sort.cpp: In function 'void increase_key(int, int, int)': heap_sort.cpp:85:5: error: 'H' was not declared in this scope H[K] += value; ^ heap_sort.cpp: In function 'int find_min()': heap_sort.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Heap Sort face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.