Uploaded by YAN VICTOR

ECE368 Project 1 Report

advertisement
ECE368 Project 1 Report
Yunlei Yan
0028847390
1. Time and space analysis
To generate the sequence, my algorithm has a time complexity of O(n^2) due to the nested for
loop and a space complexity of O(n) as I stored the number of elements of each line in to a
array.
2.
Insertion
Sort
1000
Insertion
Sort
10000
Insertion
Sort
100000
Selection
Sort
1000
Selection
Sort
10000
Selection
Sort
100000
I/O running
time(sec)
0e0
Sort running
time(sec)
0e0
Number of
Moves
1.3839e4
Number 3e-of
comparisons
3.5568e4
0e0
0e0
2.16138e5
6.22757e5
3e-2
2e-2
3.037446e6
9.617893e6
0e0
2e-2
9.2985e4
1.345274e7
0e0
2.64
1.652334e6
2.468861e9
3e-2
426
2.581654e7
3.943983e11
For both algorithm, everything grow as the size of our data grows. However, they grow on different
scales. For insertion sort, the time complexity would be O(n(logn)^2). Therefore, as the number of elements in
our sequences, the running time doesn’t increase enormously. And the number of comparisons and moves are
increased on a pretty constant scale – about 15 times for every 10 times larger data set. However, for the
selection sort, the running time and number of movements and comparisons are insanely high and increased
more than 150 times and our data set increase. Since the time complexity is O(n^2), large data set will have a
significant effect on the performance.
3. In addition to the array to be sorted, I used another array for both algorithm to keep the sequence for
my k which is relatively much smaller than our data set’s size, so the space complexity will be O(n) for
both algorithm.
Download