#2746
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 | #57359620 | Utilizator | |
Fișier | heap_sort.cpp | Dimensiune | 1.89 KB |
Data încărcării | 27 Martie 2025, 12:46 | Scor / rezultat | Eroare de compilare |
heap_sort.cpp:5:17: error: size of array 'H' is too large int H[1000000001]; ^ heap_sort.cpp: In function 'void up(int)': heap_sort.cpp:24:23: error: 'H' was not declared in this scope while (pos > 1 && H[pos] < H[parent(pos)]) { ^ heap_sort.cpp: In function 'void down(int)': heap_sort.cpp:37:37: error: 'H' was not declared in this scope if (right_son(pos) <= sz && H[right_son(pos)] < H[next_pos]) { ^ heap_sort.cpp:40:13: error: 'H' was not declared in this scope if (H[pos] <= H[next_pos]) { ^ heap_sort.cpp: In function 'void sterge_radacina()': heap_sort.cpp:51:10: error: 'H' was not declared in this scope swap(H[1], H[sz]); // interschimb radacina cu ultimul element din heap ^ heap_sort.cpp: In function 'void inserare(int)': heap_sort.cpp:59:5: error: 'H' was not declared in this scope H[sz] = x; ^ heap_sort.cpp: In function 'int minim()': heap_sort.cpp:65:12: error: 'H' was not declared in this scope return H[1]; ^ heap_sort.cpp: In function 'int main()': heap_sort.cpp:82:14: error: 'H' was not declared in this scope f >> H[i]; ^ heap_sort.cpp: In function 'int minim()': heap_sort.cpp:66: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ă.