Lecture1 PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

CSE 202: Design and Analysis

of Algorithms

Lecture 1
!
Logistics
• Instructor: Kamalika Chaudhuri (kamalika@cs)
• Office Hours: F 10:30-11:30am, 4110 EBU3B
• TAs: Chicheng Zhang(chz038@eng), Joseph
Geumlek(jgeumlek@cs)
• Office Hours: TBA
• http://cseweb.ucsd.edu/classes/sp16/cse202-a/
Algorithms

Problem Abstraction Algorithm


An Example
What is the shortest route
Problem:
from San Francisco to San Diego ?

Weighted Graph G
Node: City
Abstraction: Edge: Joins two cities
Edge weight: Distance between cities

What is the shortest path between


San Francisco and San Diego in G?
An Example
What is the shortest route
Problem:
from San Francisco to San Diego ?

Abstraction: Shortest path in a graph

Exhaustive Search,
Algorithm:
Dijkstra’s Algorithm, etc.
Algorithm Design Issues

• Correctness
• Efficiency
Algorithm Design Issues:
Correctness

• Recall: Shortest Path problem in a graph


• Does the algorithm always provide a shortest path?
Algorithm Design Issues:
Efficiency
• Recall: Shortest Path problem in a graph
• Algorithm 1: Iterate over all paths from SD to
SF, and find the one with minimum weight.
• Is this a good algorithm?
• No! Can take exponential(v) time
• Dijkstra’s algorithm takes O(e + vlog v) time
Summary
• In this class, you will learn to:
• Create abstractions from problems
• Design algorithms for abstracted problems
!

• Algorithm design issues we will look at:


• Correctness
• Efficiency
Administrivia
Prerequisites
• Mathematical class
• CSE 101 or equivalent
• Calibration Quiz Friday Apr 1 in class
• Will cover Big O notation, Recurrences, Basic
graph search, Dijkstra’s algorithm
• Calibration Quiz will not count towards grade
Textbook
• Algorithm Design,
by Jon Kleinberg, and Eva Tardos
Syllabus
• Chapters1-3: Read on your own (tested in
calibration quiz)
• Chapter 4: Greedy
• Chapter 6: Dynamic Programming
• Chapter 7: Network Flows
• Chapter 13: Randomized Algorithms
Assessment

• Homeworks (25%)
• Midterm (in-class) (35%)
• Final (in class) (35%)
• Class Participation (5%)
• Calibration quiz (0%)
Midterm and Final
• Midterm - in-class on Wed May 11
• Final - Jun 9 at 11:30am-1pm
!

• If you cannot make these dates, please do


not take the class. We will only make
exceptions for medical emergencies.
Homework Policy

• Homeworks are due in class at the


beginning of lecture
• No late homeworks will be accepted!
Collaboration Policy

• Homeworks should be done in groups of


one or two or three
• Email me the name of your group members
by Fri Apr 8
• If you need a group member, please post on
Piazza group for the class
Collaboration Policy

• You must not look for solutions to


homework problems on the internet
• If you happen to see a homework solution
somewhere, please acknowledge the source!
Collaboration Policy

• If someone (except me or TA) helps you with


your homework, acknowledge the source!
• Remember: Academic dishonesty is taken
very seriously!
• More details on this on the class website
Class Participation

• Participation in In-class Problem Sessions


• Participation on Piazza
• Top 10 answerers on Piazza will get 5%
Grading Policy

Any
! algorithm you present must:

• Be clear and unambiguous (but no code)


• Have a proof of correctness
• Have a running time analysis
• Be relatively efficient
Grading Policy: Clarity
!

• Proofs will be graded by correctness and clarity


• Your arguments should be clear and precise
• More partial credit for clearly written partial solution than
attempt to cover up holes in your argument

• Sample solutions on class website


• We’ll look at some examples in class
Algorithm Design Paradigms
Paradigm 1: Exhaustive Search

• Usually computationally inefficient


• May be useful for some small problems
Paradigm 2: Greedy Algorithms

• Build the solution piece by piece


• Examples: Dijkstra’s algorithm, Kruskal
• Does not always work correctly!
Paradigm 3: Divide and Conquer

• Divide the problem into smaller subproblems


• Solve each subproblem
• Combine the results
• Example: Mergesort
Paradigm 4: Dynamic Programming

• Define a proper notion of subtask


• Solve the subtasks by size
• Once smaller subtasks are solved, larger
ones are easy
• Example: computing the edit distance
Paradigm 5: Hill-climbing

• Start with any solution


• Improve the solution by tweaking it a little
• Continue until optimality
• Example: Flows, linear programming
Paradigm 6: Randomized
Algorithms

• Use some randomness in the algorithm to get out


of bad situations
• Usually very simple and efficient
• May not always succeed, but works with high
probability
• Example: min-cut, MAX-SAT
Intractable Problems

• No efficient solution possible, provably!


• A way out is to find a good approximate solution
Summary: Algorithm Design Paradigms

• Exhaustive Search
• Greedy Algorithms: Build a solution incrementally
• Divide and Conquer: Divide into parts, solve each
part, combine results

• Dynamic Programming: Divide into subtasks,


perform subtask by size. Combine smaller subtasks
to larger ones

• Hill-climbing: Start with a solution, improve it


• Randomized: Use some randomness
Announcement
• Email me the name of your group members
by Fri Apr 8
• No lecture on Wed Mar 30
• Calibration Quiz in class on Fri Apr 1
• Covers Big O, recurrences, basic graph
algorithms (BFS/DFS), Dijkstra’s algorithm
• TA OH will be posted on Piazza

You might also like