73 lines
6.2 KiB
Plaintext
73 lines
6.2 KiB
Plaintext
!
|
|
! Implementation of several sorting functions in Triangle by
|
|
! - Alexander Constantin constant@rbg.informatik.tu-darmstadt.de
|
|
! - Nico Rottstädt rottstae@rbg.informatik.tu-darmstadt.de
|
|
!
|
|
! This is an excercise from A. Koch's Lecture "Optimierende Compiler",
|
|
! summer term 2006 at TU Darmstadt / Germany, course homepage (German):
|
|
! http://www.esa.informatik.tu-darmstadt.de/twiki/bin/view/Lectures/OptimierendeCompilerDe.html
|
|
|
|
Wir haben uns dafür entschieden einige Implementationen von Sortieralgorithmen beizusteuern.
|
|
Genommen haben wir BubbleSort, QuickSort und HeapSort, die uns deutlich an unsere
|
|
Grundzüge der Informatik III Vorlesung bei Prof. Waldschmit erinnern.
|
|
|
|
1) Liste der implementierten Funktionen/Prozeduren
|
|
--------------------------------------------------
|
|
|
|
! Prodcedure which plots the array to standard out
|
|
! ------------------------------------------------
|
|
proc putArray(arr: array 100 of Integer)
|
|
|
|
! Heap Sort Implementation
|
|
! ------------------------
|
|
proc swap(var arr: array 100 of Integer, x : Integer, y : Integer)
|
|
proc sift(var arr: array 100 of Integer, start : Integer, count : Integer)
|
|
proc heapsort(var arr: array 100 of Integer, count : Integer)
|
|
|
|
! Quick Sort Implementation
|
|
! -------------------------
|
|
proc quicksort(var arr : array 100 of Integer, l : Integer, r : Integer)
|
|
|
|
! Bubble Sort Implementation
|
|
! --------------------------
|
|
proc bubblesort(var arr: array 100 of Integer, count : Integer)
|
|
|
|
! Check validity of array sorting and plot result to standard out
|
|
! ---------------------------------------------------------------
|
|
proc checkArraySorting(arr: array 100 of Integer, count : Integer, var valid : Boolean)
|
|
|
|
! Array Entries (Randoms generated in Java)
|
|
! -----------------------------------------
|
|
proc buildTestArray1(var arr: array 100 of Integer) ~
|
|
|
|
2) Eingabe
|
|
----------
|
|
im Programm
|
|
|
|
3) Ausgabe des Programms
|
|
------------------------
|
|
|
|
bubble
|
|
[10690, 21584, 24270, 3653, 1307, 17096, 10992, 9183, 11046, 13206, 28037, 7567, 22399, 10778, 11956, 23117, 11576, 6163, 16207, 12336, 2700, 6146, 2338, 18116, 15568, 12391, 26919, 25563, 17520, 27064, 23250, 9326, 11345, 3436, 10496, 20940, 8102, 25909, 23299, 28153, 25820, 17943, 10678, 12475, 13277, 7064, 29208, 354, 405, 1038, 22731, 32, 21053, 24448, 8994, 27712, 28553, 30560, 12371, 9016, 32653, 7631, 30419, 5939, 27820, 20465, 30613, 29277, 22185, 1873, 14971, 9918, 24685, 31488, 7415, 26915, 7637, 6607, 1389, 2114, 10343, 874, 27532, 14268, 31086, 14099, 6000, 16760, 5041, 4867, 32507, 7729, 18035, 6220, 17051, 14586, 26429, 13230, 30718, 6103]
|
|
sorting: invalid
|
|
[32, 354, 405, 874, 1038, 1307, 1389, 1873, 2114, 2338, 2700, 3436, 3653, 4867, 5041, 5939, 6000, 6103, 6146, 6163, 6220, 6607, 7064, 7415, 7567, 7631, 7637, 7729, 8102, 8994, 9016, 9183, 9326, 9918, 10343, 10496, 10678, 10690, 10778, 10992, 11046, 11345, 11576, 11956, 12336, 12371, 12391, 12475, 13206, 13230, 13277, 14099, 14268, 14586, 14971, 15568, 16207, 16760, 17051, 17096, 17520, 17943, 18035, 18116, 20465, 20940, 21053, 21584, 22185, 22399, 22731, 23117, 23250, 23299, 24270, 24448, 24685, 25563, 25820, 25909, 26429, 26915, 26919, 27064, 27532, 27712, 27820, 28037, 28153, 28553, 29208, 29277, 30419, 30560, 30613, 30718, 31086, 31488, 32507, 32653]
|
|
sorting: OK
|
|
quick
|
|
[10690, 21584, 24270, 3653, 1307, 17096, 10992, 9183, 11046, 13206, 28037, 7567, 22399, 10778, 11956, 23117, 11576, 6163, 16207, 12336, 2700, 6146, 2338, 18116, 15568, 12391, 26919, 25563, 17520, 27064, 23250, 9326, 11345, 3436, 10496, 20940, 8102, 25909, 23299, 28153, 25820, 17943, 10678, 12475, 13277, 7064, 29208, 354, 405, 1038, 22731, 32, 21053, 24448, 8994, 27712, 28553, 30560, 12371, 9016, 32653, 7631, 30419, 5939, 27820, 20465, 30613, 29277, 22185, 1873, 14971, 9918, 24685, 31488, 7415, 26915, 7637, 6607, 1389, 2114, 10343, 874, 27532, 14268, 31086, 14099, 6000, 16760, 5041, 4867, 32507, 7729, 18035, 6220, 17051, 14586, 26429, 13230, 30718, 6103]
|
|
sorting: invalid
|
|
[32, 354, 405, 874, 1038, 1307, 1389, 1873, 2114, 2338, 2700, 3436, 3653, 4867, 5041, 5939, 6000, 6103, 6146, 6163, 6220, 6607, 7064, 7415, 7567, 7631, 7637, 7729, 8102, 8994, 9016, 9183, 9326, 9918, 10343, 10496, 10678, 10690, 10778, 10992, 11046, 11345, 11576, 11956, 12336, 12371, 12391, 12475, 13206, 13230, 13277, 14099, 14268, 14586, 14971, 15568, 16207, 16760, 17051, 17096, 17520, 17943, 18035, 18116, 20465, 20940, 21053, 21584, 22185, 22399, 22731, 23117, 23250, 23299, 24270, 24448, 24685, 25563, 25820, 25909, 26429, 26915, 26919, 27064, 27532, 27712, 27820, 28037, 28153, 28553, 29208, 29277, 30419, 30560, 30613, 30718, 31086, 31488, 32507, 32653]
|
|
sorting: OK
|
|
heap
|
|
[10690, 21584, 24270, 3653, 1307, 17096, 10992, 9183, 11046, 13206, 28037, 7567, 22399, 10778, 11956, 23117, 11576, 6163, 16207, 12336, 2700, 6146, 2338, 18116, 15568, 12391, 26919, 25563, 17520, 27064, 23250, 9326, 11345, 3436, 10496, 20940, 8102, 25909, 23299, 28153, 25820, 17943, 10678, 12475, 13277, 7064, 29208, 354, 405, 1038, 22731, 32, 21053, 24448, 8994, 27712, 28553, 30560, 12371, 9016, 32653, 7631, 30419, 5939, 27820, 20465, 30613, 29277, 22185, 1873, 14971, 9918, 24685, 31488, 7415, 26915, 7637, 6607, 1389, 2114, 10343, 874, 27532, 14268, 31086, 14099, 6000, 16760, 5041, 4867, 32507, 7729, 18035, 6220, 17051, 14586, 26429, 13230, 30718, 6103]
|
|
sorting: invalid
|
|
[32, 354, 405, 874, 1038, 1307, 1389, 1873, 2114, 2338, 2700, 3436, 3653, 4867, 5041, 5939, 6000, 6103, 6146, 6163, 6220, 6607, 7064, 7415, 7567, 7631, 7637, 7729, 8102, 8994, 9016, 9183, 9326, 9918, 10343, 10496, 10678, 10690, 10778, 10992, 11046, 11345, 11576, 11956, 12336, 12371, 12391, 12475, 13206, 13230, 13277, 14099, 14268, 14586, 14971, 15568, 16207, 16760, 17051, 17096, 17520, 17943, 18035, 18116, 20465, 20940, 21053, 21584, 22185, 22399, 22731, 23117, 23250, 23299, 24270, 24448, 24685, 25563, 25820, 25909, 26429, 26915, 26919, 27064, 27532, 27712, 27820, 28037, 28153, 28553, 29208, 29277, 30419, 30560, 30613, 30718, 31086, 31488, 32507, 32653]
|
|
sorting: OK
|
|
|
|
4) Variationen
|
|
--------------
|
|
|
|
In der Procedure wird das Test Array definiert, da wir aber an die Limitation des Compiler für die
|
|
maximale Anweisungsanzahl gestossen sind, konnten wir nicht mehrere Test Arrays nutzen.
|
|
Es sind aber noch weitere Test Arrays in dieser Prozedur auskommentiert vorhanden.
|
|
|
|
[EOF] |