CSC165H1 Lecture Notes - Lecture 13: Return Statement, Texas State Highway Loop 1, For Loop
cherryberry1035 and 38883 others unlocked
3
CSC165H1 Full Course Notes
Verified Note
3 documents
Document Summary
Given an algorithm find an approximate of input size for large inputs of steps as a function. When we perform a runtime analysisof an algorithm we almostalways communicate a q c j as the result. Return statement and passingarguments to afunction call variable lookup y x 13. Examplesof code that can take non constant tome cie takeslongerasinputgrows. Key idea addupthe total runtime fromeach loop iteration. Example def f ni int h 30 for 2 in range ch. Analysis start from the innermost loop and work our way out. The loop body printcity takes constant time so it counts. There are n iterations in total c j. 1 n o l t i t m2. But this is onlyfor one iterationof loop 1. Each iteration takes n steps cthe cost of loop 2. There are h iterations in loop 1 c2 0 n t h th n h2 n u s n l n3 t n t i.