-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathw1d2
64 lines (48 loc) · 1.33 KB
/
w1d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
euclids elements
Mathematics for programmers
complexity
functino types - how they grow
what is 0/0?
1/1 1/0 0/1 - consider
division \expressed a multi
0/0 = ? => 0 * ? = 0 ===== ? can be anyyting ; undefined
domain input
range output
func types we care about
linear
constant
quad
sqaure root
expo
log
factorial
greather than n^2
take out n^2 part -> optimize and run it n times
sqrt runtime ->>>>>>>>>>>>>>> whaaaaaaaaa
figuring out with a number is a prime - only have to chekc up to square root of number
ex2. precomputing
exponential runtime
ex1. combinations and permutations
factorial runtmie
fibonacci no memoization
limits
as x become closer to some value c, what does function do
1/x = x ^ 0 / x ^ 1
same rates -> look at coefficients
* look at rates to figure limits
review asymptotes? horizzatonal vs verticla
horizaontl: take x -> inf
vertical: set dominornator to 0 and solve
nlog(n) -> pseudolinear , best runtimes for sorting algos
MODULAR ARITHMATIC
2 major uses
iterate over a set and go back to the start
security
take numberline an mkae it a circle
7%3 = 1
^ hard to figure out based only on input form x %3 = 1
combinations and permutations
n : number of elememtns
r : number of things in choice
nPr = n! / (n-r)! -> permutation order matters
combinations combining choices; order doesnt matter -> nCr = n! / ((r!)(n-r)!)