For example, some sorting algorithms with a complexity of O(n^2) often run considerably faster if the list that it receives as input is (almost) sorted other sorting algorithms with a complexity of O(n^2) always take the same amount of time, no matter what state the list is in. For example, big-Oh analysis concerns the worst case scenario. However, complexity analysis has a number of limitations. For example, if an algorithm has a complexity of O(1), then it always runs in the same amount of time, no matter what the size of the input is if it O(n), then the time it takes for the algorithm to run is proportional to the size of the input. You will recall that in complexity analysis we express the time an algorithm takes to run as a function of the size of the input, and we used the big-Oh notation. Module 7 showed that one way of comparing different algorithms for accomplishing the same task is complexity analysis.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |