12.07.2015 Views

slides - Unisinos

slides - Unisinos

slides - Unisinos

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Max-heapfymaxHeapfy(A, 0, A.length)25public static void maxHeapfy (int a[], int i, int N) {int maior=i;int l = 2*i+1; // posicao do filho esquerdo de iint r = 2*i+2; // posicao do filho direito de iif (l < N && a[l]>a[i]) maior=l;if (r < N && a[r]>a[maior]) maior = r;if (maior!=i) {int T = a[i];a[i] = a[maior];a[maior] = T;maxHeapfy (a, maior, N);}}2512 2218 2209 18 10 1309 12 10 1333

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!