CS 1110, Week 12 Notes
CS 1110, Week 12 Notes CS 1110-002
Popular in Intro to Computing using Python
verified elite notetaker
Popular in ComputerScienence
This 2 page Class Notes was uploaded by Eunice on Friday April 22, 2016. The Class Notes belongs to CS 1110-002 at Cornell University taught by Lee, Van Loan in Spring 2016. Since its upload, it has received 16 views. For similar materials see Intro to Computing using Python in ComputerScienence at Cornell University.
Reviews for CS 1110, Week 12 Notes
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 04/22/16
CS 1110 Van Loan and Lee Spring 2016 April 19, 2016 Redefining computations (+ or -) o example: SimpleDate class create methods to calculate in leap years and lengths of months redefine + to add days instead of attempting concatenation by creating an __add__ method similarly, for – and subtraction, __sub__ for ==, __eq__ copying objects: o B = copy(A) copying an object doesn’t reproduce a copy of its references o B = deepcopy(A) complete copy including its references New Material (not on prelim 2) o Recursion functions that call themselves patterns that are defined by the terms of itself consider levels at each level, execute a certain procedure respective to the level (with triangles and fractals, consider each inner triangle a new level) factorial example if an execution can be reapplied with n-1 (n being the major variable at hand), recursion could be applied a base case: the condition or point at which the recursion stops April 21, 2016 Searching a List (example being searching a list of integers) o Linear Search: data is unordered method: iterate and go down a line no match case: return -1 while implementation vs. for implementation while: while there’s no match for: check for each whether it’s a match if there are multiple cases, without further specification, it will just return the first match case o Binary search: assume/specify that the list to be searched is sorted from little to big when the length of the list increased by a certain constant, the time it takes to search the list does not equally scale method: check half, discard the half that does not include the match ex. if you have a name to find in an alphabetized list, check half and if the name falls within the letters of that half math: log 2n) code: find midpoint (Mid), discard either preceding or following half (halving the size of the search space) o L: left endpoint; R: right endpoint; Mid: (L+R)/2 at the end of the loop, compare the end points (which are the two remaining values to check for matches) o a recursion o Benchmarking (check how long a code takes) the longer the list, the binary method is fastest the linear method, for loop is second; linear method, while loop is the slowest while loop test condition is complicated
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'