of 43

# CS32 Discussion Week 7 - muhao/cs32s18/week7.pdf  CS32 Discussion Week 7 Muhao Chen muhaochen@ucla.edu

Jul 29, 2018

## Documents

dinhbao

• CS32 DiscussionWeek 7

Muhao Chen

muhaochen@ucla.edu

http://yellowstone.cs.ucla.edu/~muhao/

1

mailto:muhaochen@ucla.eduhttp://yellowstone.cs.ucla.edu/~muhao/

• Outline

Big-O Notation

Sorting

Tree

2

• Complexity

Quantify the efficiency of a program.

The magnitude of time and space cost for an algorithm given certain size of input.Time complexity: quantifies the run time.Space complexity: quantifies the usage of the

memory (or sometimes hard disk drives, cloud disk drives, etc.).

3

• 4

• 5

• Formal Definition of Big-O

Let T(n) be the function that measures the runtime of the program given n size of input

Let g(n) be another function defined on the real number field. T(n) = O(g(n)) iff M > 0 and N > 0 s.t. n>N : T(n)

M*g(n)

6

When the input size n grows above certain scale N, the runtime T(n) is of the same or less

magnitude of the function g inside O( )Upper bound

• 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

• Permutation

32

void permutation(vector& nums, int start) {if (start == nums.size() - 1) {

for(int i=0; i

• 33

• Tree

34

• 35

• 36

• 37

n - 1

• 38

• 39

20+21++2h=2h+1-1

• 40

• 41

• 42

0

• Bugs in your software are actually special features :)

43

Related Documents See more >
##### Week 9 writing discussion
Category: Education
##### Discussion topic for week 1
Category: Documents
##### Week 1 discussion 2 confidentiality final
Category: Documents
##### Discussion Week 13-Excretion - Animal 2019-11-21آ ...
Category: Documents
##### Sort and Tree 2014 Spring CS32 Discussion Jungseock Joo.
Category: Documents
##### Week 1 discussion 2 edu 352
Category: Documents