Big-O

Big-O

https://leetcode.com/explore/interview/card/leetcodes-interview-crash-course-data-structures-and-algorithms/715/introduction/4654/

O: order of magnitude of complexity (复杂度的数量级)
Time complexity: the amount of time the algorithm needs to run relative to the input size.
Space complexity: the amount of memory allocated by the algorithm when run relative to the input size.
Typically, people care about having a better time complexity more than having a better space complexity.

The point of computational complexity is to analyze how an algorithm scales with the input. Let's say you have two algorithms. One runs in O(100n) and the other runs in O(5n). Even though the second algorithm runs 20x faster, both algorithm's operations grow linearly with n. If you double n, then both algorithms will take 2x longer regardless of what the coefficients are.

posted @ 2022-12-26 11:45  shendawei  阅读(70)  评论(0)    收藏  举报