data structure and algorithm

hankyulee·2022년 5월 22일
0

Swift coding test 준비

목록 보기
55/57

complexity

Since the array is sorted, you can, right off the bat, drop half of the comparisons necessary by checking the middle value. for example binary search.

The more data you have, the more the halving effect scales. Thus, you can see that the graph appears to approach horizontal.

->the more data, the more effectivness.

Another common time complexity you’ll encounter is quasilinear time. Quasilinear time algorithms perform worse than linear time but dramatically better than quadratic time. They are among the most common algorithms you’ll deal with. An example of a quasilinear time algorithm is Swift’s sort method.

->nlogn

quadratic algorithms such as insertion sort can be faster than quasilinear algorithms, such as mergesort, if the data set is small.

->if data set is small..

->compiled code makes it faster.

ref - https://www.raywenderlich.com/books/data-structures-algorithms-in-swift/v3.0/chapters/2-complexity

0개의 댓글