CS171 Introduction to Computer Science II

Download Report

Transcript CS171 Introduction to Computer Science II

CS171 Introduction to Computer
Science II
The Revenge of the Graphs
How does the Internet route packets?
How does the Internet route packets?
Graphs
• Simple graphs
• Algorithms
–
–
–
–
•
•
•
•
Depth-first search
Breadth-first search
shortest path
Connected components
Directed graphs
Weighted graphs
Shortest path
Minimum Spanning Tree
Every connected graph
has a spanning tree
Aside:
How many spanning trees in a graph?
• Let’s focus on complete graphs where all
edges are present.
2 3 4
5
6
7
8
9
1 3 16 125 1296 16807 262144 4782969
10
100000000
Aside:
How many spanning trees in a graph?
• This is Cayley’s formula:
There are 𝑛𝑛−2 labeled spanning trees
in a complete graph with 𝑛 vertices
2 3 4
5
6
7
8
9
1 3 16 125 1296 16807 262144 4782969
10
100000000
Applications
• Phone/cable network design
– Minimizes cost
• Approximation algorithms for NP-hard
problems
• Cluster analysis
• Handwriting recognition
• Image segmentation
• …
Prim Demo
Questions
• If all the edges of a graph have distinct
weights, what can we say about the MST?
• How do you find a maximum spanning tree?
• How do you create a maze?
–
…ing!
http://en.wikipedia.org/wiki/File:MAZE_30x20_Prim.ogv
Review on Thursday
• Last class!
• What topics should we go through?
Course topics
• Data structures
– Fundamental data structures: arrays, linked lists
– Operations (algorithms that maintain and use the data structure):
search, insertion, deletion, sort
– Abstract data types (a data structure with its associated operations):
stacks, queues, trees, hash tables, graphs
• Algorithms
– Fundamental algorithms: sort, search, recursion, DFS, Dijkstra, MST
– Algorithm analysis: runtime complexity, Big-O notation
• Programming
– Java programming techniques – through hands-on homeworks!
– Applications: scientific, recreational, social networks, etc.
7/21/2015
26
Evaluations!
• Please fill out the College and Department
course evaluations for CS171
– I can look up your major…