{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

eecs280.discussion.week8

# eecs280.discussion.week8 - Week 8 Discussion Binary Search...

This preview shows pages 1–8. Sign up to view the full content.

Week 8 Discussion Binary Search Classes Inheritance

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Project 3 and Exams Project 3 due this Wednesday Worth most out of all the projects. Midterm exams will be given back in class. Come to Office Hours or stick around after discussion (if there's time) if you have any questions.
Binary Search Given a list of numbers: 5, 10, 3, 15, 20, 9, 7 What is the best way to find any given number?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Binary Search Given a list of numbers: 5, 10, 3, 15, 20, 9, 7 What is the best way to find any given number? Just go through the list, check if the current number is the number, check the next number, etc...
Binary Search Very slow, especially if you have 1000s of numbers to keep track of. Can anyone think of a better way? (maybe if we sorted the list first?)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Binary Search Binary Search: Requires a sorted list Look at middle element. If current element is less than your target, search next in the right half. If current element is greater than your target, search next in the left half. If current element is your target, hooray! Continue until you find the target. Log2(n) comparisons on average. Since with every comparison you cut the search space in half.
Binary Search Search for 23: 3 5 7 9 10 15 20 23 29 31 3 5 7 9 10 15 20 23 29 31 3 5 7 9 10 15 20 23 29 31 3 5 7 9 10 15 20 23 29 31 3 5 7 9 10 15 20 23 29 31

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 23

eecs280.discussion.week8 - Week 8 Discussion Binary Search...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online