{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cse101-wi12-Week2Discussion

# cse101-wi12-Week2Discussion - 2 What is the time complexity...

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

CSE 101 - Discussion Homework Questions, Examples, Master Theorem

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

View Full Document
Agenda First 25 minutes (max) for homework questions. Due tomorrow at the START of lecture! Chapter 3 example problem Divide and conquer: Master theorem
Chap. 3, Ex. 3.14 Chapter 3 suggests an algorithm for linearization (topological sorting), which repeatedly removes source nodes from the graph (page 101). Show that this algorithm can be implemented in linear time. Hint: What do we know about the indegree of source nodes? How quickly can we Fnd the indegree of all nodes in the graph?

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

View Full Document
Master Theorem Simple method for providing the time complexity (big- O ) of a recurrence relation. Divide and conquer! Page 49 in Algorithms
Master Theorem What is a ? What is b ?

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

View Full Document
Master Theorem Mergesort T(n) = 2T(n/2) + O(n) What is the time complexity of Mergesort?
Master Theorem T(n) = 2T(n/2) + O(n

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

View Full Document

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.

Unformatted text preview: 2 ) What is the time complexity? Master Theorem T(n) = 4T(n/4) + O(1) What is the time complexity? Master Theorem T(n) = T(sqrt(n)) + O(1) Can you solve these with the master theorem? T(n) = T(n-1) + O(n) Closing Riddle • A bunch of people are living on an island when a visitor comes and tells them that everyone with blue eyes must leave as soon as possible. There is a Fight out every evening at 8 pm. • Every person can see everyone else’s eye color but not their own (and no telling each other. ..) • It’s not known how many people have blue eyes except that at least one person must. • How many days will it take the blue eyed people to leave the island? • Hint: What happens when one person has blue eyes? Do they know? ±rom “Cracking the Coding Interview” (McDowell, 2011)...
View Full Document

{[ snackBarMessage ]}

### Page1 / 10

cse101-wi12-Week2Discussion - 2 What is the time complexity...

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

View Full Document
Ask a homework question - tutors are online