소개글
난수를 발생, 각 정렬방법의 실제 실행 시간 측정 및 비교bubble Sort, selection Sort, insertion Sort, quick Sort, mergeSort, heap Sort
#include
#include
#include
#include
using namespace std;
const int SIZE = 30000;
void sort(int size);
void bubbleSort(int A[], int n);
void selectionSort(int A[], int n);
void insertionSort(int A[], int n);
void quickSort(int A[], int low, int high);
void mergeSort(int A[], int low, int high, int size);
void heapSort(int A[], int n);
void makeDownHeap(int a[], int i, int size);
void merge(int A[], int low, int middle, int high, int size);
void swap(int &a, int &b);
void displayFirstTwenty(int A[]);
clock_t start, finish;
void main()
{
int i;
for (i = 10000; i <= SIZE; i+=5000) {
sort(i);
cout << endl << endl;
}
}
...
output -----
The number of integers to sort: 10000
Elapsed time for Bulbble Sort: 1.78100 seconds
0 1 2 7 8 11 12 13 14 16
19 27 28 29 31 34 37 38 43 48
Elaped time for Selection Sort: 0.31300 seconds
0 1 2 7 8 11 12 13 14 16
19 27 28 29 31 34 37 38 43 48
Elaped time for Insertion Sort: 0.20300 seconds
0 1 2 7 8 11 12 13 14 16
19 27 28 29 31 34 37 38 43 48
Elaped time for Quick Sort: 0.00000 seconds
0 1 2 7 8 11 12 13 14 16
....
컴파일 실행환경
Microsoft visual c++ 6.0참고 자료
없음프로그램소스 연관자료
이 자료와 함께 구매한 자료
- insertion sort 0페이지
- Bubble Sort 0페이지
- Shell Sort 0페이지
- 알고리즘 정렬(Sort)과 실행시간 7페이지