×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

or

by: Eunice

16

0

2

# CS 1110, Week 12 Notes CS 1110-002

Eunice
Cornell

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

Redefining Computations Copying Recursion (Linear and Binary Search)
COURSE
Intro to Computing using Python
PROF.
Lee, Van Loan
TYPE
Class Notes
PAGES
2
WORDS
CONCEPTS
CS, Python
KARMA
25 ?

## 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

×

×

### What is Karma?

#### 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

×

×

### BOOM! Enjoy Your Free Notes!

×

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'

## Why people love StudySoup

Jim McGreen Ohio University

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Kyle Maynard Purdue

#### "When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the material...plus I made \$280 on my first study guide!"

Jim McGreen Ohio University

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Parker Thompson 500 Startups

#### "It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com