Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi A - F > Algoritmi e strutture dati > [Bubblesort vs. Quicksort] Bellissimo!!
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
CowBoy
.arcimaestro.

User info:
Registered: May 2006
Posts: 294 (0.04 al dì)
Location: Milano
Corso: F49 - Informatica
Anno: Laureato F49
Time Online: 3 Days, 13:40:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[Bubblesort vs. Quicksort] Bellissimo!!

Che la sfida abbia inizio:

http://www.youtube.com/watch?v=vxENKlcs2Tw

__________________
.. ±·ø·±-`` MuSiC iS My LanGuAGe ´´-±·ø·± ..

15-02-2011 17:34
Click Here to See the Profile for CowBoy Click here to Send CowBoy a Private Message Find more posts by CowBoy Add CowBoy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
xSharKMaNx
un gioco della follia

User info:
Registered: Sep 2007
Posts: 1477 (0.23 al dì)
Location:
Corso: F49
Anno: Laureato
Time Online: 10 Days, 17:15:29 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

http://www.geek.com/articles/geek-c...fects-20100819/

Buona visione ;)

__________________
Perché, mentre il manganello può sostituire il dialogo, le parole non perderanno mai il loro potere; perché esse sono il mezzo per giungere al significato, e per coloro che vorranno ascoltare, all'affermazione della verità. E la verità è che c'è qualcosa di terribilmente marcio in questo paese. (V)

I popoli non dovrebbero aver paura dei propri governi, sono i governi che dovrebbero aver paura dei popoli. (T.J)

15-02-2011 19:47
Click Here to See the Profile for xSharKMaNx Click here to Send xSharKMaNx a Private Message Find more posts by xSharKMaNx Add xSharKMaNx to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
CowBoy
.arcimaestro.

User info:
Registered: May 2006
Posts: 294 (0.04 al dì)
Location: Milano
Corso: F49 - Informatica
Anno: Laureato F49
Time Online: 3 Days, 13:40:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Dubbio quicksort

Ho scritto l'algoritmo quicksort in VBA secondo le indicazioni trovate nella dispensa di Goldwurm, poiché svolgendo i calcoli a mano non riuscivo ad ordinare la sequenza in modo corretto.

L'array viene rappresentato dalla colonna A(A[1], A[2]... A[n]), contenente in celle consecutive una sequenza di numeri da ordinare. La pila viene rappresentata dalle colonne C e D.

Provo ad eseguire l'algoritmo e nella maggior parte delle volte la sequenza non è ordinata... sapete dirmi dove sto sbagliando?


HO RISOLTO!!! IL CODICE ADESSO FUNZIONA

code:
Function partition(ByVal p As Integer, ByVal q As Integer) As Integer Dim i As Integer Dim j As Integer i = p + 1 j = q While (i <= j) While (Cells(j, 1) > Cells(p, 1)) j = j - 1 Wend While ((Cells(i, 1) <= Cells(p, 1)) And i <= j) i = i + 1 Wend If i < j Then scambia i, j i = i + 1 j = j - 1 End If Wend scambia p, j partition = j End Function Function scambia(ByVal p As Integer, ByVal q As Integer) Dim t As Integer t = Cells(p, 1) Cells(p, 1) = Cells(q, 1) Cells(q, 1) = t End Function Function random(ByVal a As Integer, ByVal b As Integer) As Integer random = a + Rnd * (b - a) End Function Function quicksort(ByVal a As Integer, ByVal b As Integer) Dim p As Integer Dim q As Integer Dim k As Integer Dim l As Integer Dim x As Integer ' pila Dim s As Integer ' stop Dim i As Integer Dim j As Integer p = a q = b x = 0 s = 0 Do While p < q k = random(p, q) scambia p, k l = partition(p, q) If l - p < q - l Then i = l + 1 j = q q = l - 1 Else i = p j = l - 1 p = l + 1 End If x = x + 1 Cells(x, 3) = i Cells(x, 4) = j Wend If x <> 0 Then p = Cells(x, 3) q = Cells(x, 4) x = x - 1 Else s = 1 End If Loop While (s = 0) End Function Sub exec() quicksort 1, Application.WorksheetFunction.Count(Range("A:A")) ' quicksort da 1 a n End Sub


Potete provarlo sul foglio di lavoro nel post successivo...

__________________
.. ±·ø·±-`` MuSiC iS My LanGuAGe ´´-±·ø·± ..

Last edited by CowBoy on 16-02-2011 at 04:33

15-02-2011 21:17
Click Here to See the Profile for CowBoy Click here to Send CowBoy a Private Message Find more posts by CowBoy Add CowBoy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
CowBoy
.arcimaestro.

User info:
Registered: May 2006
Posts: 294 (0.04 al dì)
Location: Milano
Corso: F49 - Informatica
Anno: Laureato F49
Time Online: 3 Days, 13:40:27 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Worksheet:

Attachment: quicksort.rar
This has been downloaded 4 time(s).

__________________
.. ±·ø·±-`` MuSiC iS My LanGuAGe ´´-±·ø·± ..

Last edited by CowBoy on 16-02-2011 at 04:41

15-02-2011 21:22
Click Here to See the Profile for CowBoy Click here to Send CowBoy a Private Message Find more posts by CowBoy Add CowBoy to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 09:41.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.106 seconds (64.84% PHP - 35.16% MySQL) con 23 query.