Description | Sorting algorithms |
Header file | LSort.h |
Author | Camil Demetrescu, Irene Finocchi, Francesco Iovine |
Created | Nov 25, 2003 |
Last updated | Nov 23, 2005 |
Constants |
|
LSort_ID |
Functions |
|
void LSort_Selection (void* inItems, ui4 inItemsCount, LType_TType inItemType); void LSort_Insertion (void* inItems, ui4 inItemsCount, LType_TType inItemType); void LSort_Bubble (void* inItems, ui4 inItemsCount, LType_TType inItemType); void LSort_RecMerge (void* inItems, ui4 inItemsCount, LType_TType inItemType); void LSort_IterMerge (void* inItems, ui4 inItemsCount, LType_TType inItemType); void LSort_RecQuick (void* inItems, ui4 inItemsCount, LType_TType inItemType); void LSort_Shell (void* inItems, ui4 inItemsCount, LType_TType inItemType); |
Function | Arguments | Description | Returns | Throws |
Selection | void* inItems | Works on inItemsCount items with
type descriptor inItemType contained in the array pointed to by
inItems. Sorts the array using selectionSort. |
- | - |
ui4 inItemsCount | ||||
LType_TType inItemType | ||||
Insertion | void* inItems | Works on inItemsCount items with
type descriptor inItemType contained in the array pointed to by
inItems. Sorts the array using insertionSort. |
- | - |
ui4 inItemsCount | ||||
LType_TType inItemType | ||||
Bubble | void* inItems | Works on inItemsCount items with
type descriptor inItemType contained in the array pointed to by
inItems. Sorts the array using bubbleSort. |
- | - |
ui4 inItemsCount | ||||
LType_TType inItemType | ||||
RecMerge | void* inItems | Works on inItemsCount items with
type descriptor inItemType contained in the array pointed to by
inItems. Sorts the array using the recursive implementation of Mergesort. |
- | - |
ui4 inItemsCount | ||||
LType_TType inItemType | ||||
IterMerge | void* inItems | Works on inItemsCount items with
type descriptor inItemType contained in the array pointed to by
inItems. Sorts the array using the iterative bottom-up implementation of Mergesort. |
- | - |
ui4 inItemsCount | ||||
LType_TType inItemType | ||||
RecQuick | void* inItems | Works on inItemsCount items with
type descriptor inItemType contained in the array pointed to by
inItems. Sorts the array using Quicksort. The pivot is chosen as the median of three randomly chosen items. |
- | - |
ui4 inItemsCount | ||||
LType_TType inItemType | ||||
Shell | void* inItems | Works on inItemsCount items with
type descriptor inItemType contained in the array pointed to by
inItems. Sorts the array using Shellsort. The decreasing sequence of step sizes is n/2, n/4, n/8, ..., 2, 1. |
- | - |
ui4 inItemsCount | ||||
LType_TType inItemType |
#include "LSort.h" #include "LSystem.h" int main(){ ui4 i, k = 5, theItems[11] = { 34, 12, 6, 9, 33, 11, 4, 3, 11, 23, 26 }; /* print array */ for (i = 0; i < 11; ++i) LSystem_Print("%lu ", theItems[i]); LSystem_Print("\n"); /* sort array */ LSort_RecQuick(theItems, 11, LType_UI4); /* print sorted array */ for (i = 0; i < 11; ++i) LDebug_Print("%lu ", theItems[i]); LSystem_Print("\n"); return 0; }