Sorting and Efficiency
In my entry for last week, I mentioned that Mr. Heap introduced us to two new sorting methods. I learned very quickly in CSC108 that computer science is more about building a program that works; proper sorting and developing an efficient program emphasizes that.
Sorting in computer science refers to arranging a number of elements in a certain order whether it is ascending or descending, by smallest or largest or by highest or lowest value.This may seem unnecessary but it can significantly cut down on the number of steps needed to accomplish a task. Furthermore, some methods such as binary search require an object containing elements to be sorted. Some programs even require data to be sorted in order to function properly. Because of this, sorting is essential to writing organized code.
Efficiency, also known as performance, describes the number of steps executed when a program is run. This can be determined through finding the algorithm complexity; the big-oh of the program. I mentioned in an earlier entry that the big-oh of a program describes the number of steps taken in the worst case input or the maximum number of steps a program will take given any input. Knowing the big-ohs of programs makes it very easy to compare efficiencies. For example, program 1 with big-oh O(log n) is more efficient than program 2 with big-oh O(n^2); in their worst cases, program 1 will take fewer steps than program 2 given that the size of the input is sufficiently large enough for both programs
No comments:
Post a Comment