CSC165H1 Lecture Notes - Lecture 13: Return Statement, Texas State Highway Loop 1, For Loop

33 views3 pages
School
Course
Professor
cherryberry1035 and 38883 others unlocked
CSC165H1 Full Course Notes
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.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers