Skip to content

Commit 6ca8397

Browse files
committed
fd
1 parent 709d240 commit 6ca8397

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

doc/时间复杂度.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
对于T(n) = a*T(n/b)+c*n^k;T(1) = c 这样的递归关系,有这样的结论:
2+
if (a > b^k) T(n) = O(n^(logb(a)));
3+
if (a = b^k) T(n) = O(n^k*logn);
4+
if (a < b^k) T(n) = O(n^k);
5+
6+
特别的,对于b=2,
7+
8+
a=1, b=2,k=1,
9+
T(n)=T(n/2)+n=O(n)
10+
11+
a=2, b=2, k=1
12+
T(n)=2T(n/2)+n=O(nlgn)
13+
14+
a=1, b=2, k=0
15+
T(n)=T(n/2)+c=O(lgn)

solution/src/main/java/com/inuker/solution/MedianOfTwoSortedArrays.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
* https://leetcode.com/articles/median-of-two-sorted-arrays/
66
*/
77

8+
/**
9+
* 这题复杂度为O(log(min(m,n)))
10+
* 因为当len1=0时就直接返回结果了,而每次迭代长度都缩短一半
11+
*/
812
public class MedianOfTwoSortedArrays {
913

1014
public double findMedianSortedArrays(int[] nums1, int[] nums2) {

0 commit comments

Comments
 (0)