![]() |
Show 150 posts per page |
.dsy:it. (http://www.dsy.it/forum/)
- Algoritmi e strutture dati (http://www.dsy.it/forum/forumdisplay.php?forumid=207)
-- [Algoritmi] MergeSort (http://www.dsy.it/forum/showthread.php?threadid=18561)
Algoritmi MergeSort
Qualcuno mi può spiegare come si applica il mergesort sull' input
A= 7 5 10 6 9 ?
che dalle dispende non ci arrivo
__________________
La vita è una jungla!
Se non ricordo male il merge si basa dul paradigma divide et impera, per cui divido in due l'array A, ad es. a1=7 5 e a2=10 6 9
divido a2 in a21=10 6 e a22=9.
Faccio gli scambi in a1 e a21, quindi avrò a1=5 7 e a21=6 10, alla fine mi trovo con: 5 7 6 10 9 a questo punto confronto ogni elem. con quello successivo cioè 5 è < 7 quindi ok, 7 non è < 6 per cui gli scambio, e così via.
Credo che sia questo il principio, purtroppo la mia memoria non è infallibile per cui prendi con la dovuta cautela ciò che ho scritto sopra.
http://www.informatik.uni-stuttgart...merge_sort.html
__________________
When once you have tasted flight, you will walk the earth, forever more, with your eyes turned skyward. For there you have been, and there you long to return.
“Dovere, tempo, destino, tutto tende a separarci e, di fatto, ci separa. Ma il sentimento non conosce frontiere e mi unisce a te come se avessi sempre la mia mano sulla tua"
grazie.
E' tutto chiaro.
__________________
La vita è una jungla!
Un'altra pagina che spiega il funzionamento di merge sort, con tanto di esempietto interattivo!
http://www.iti.fh-flensburg.de/lang...erge/mergen.htm
| All times are GMT. The time now is 19:14. | Show all 5 posts from this thread on one page |
Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.