Final Cheat Sheet

# Final Cheat Sheet - 1 Graphs i ii iii iv Undirected two way...

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

1) Graphs i) Undirected – two way edges ii) Directed – one way edges iii) Weighted – each edge has a cost iv) In hash table: keys – vertices, entries - distances b) Adjacency Lists i) Representation (1) 2 5 (2) 1 5 3 4 (3) 2 4 (4) 2 5 3 (5) 1 2 4 ii) Better when |E| << V 2 (1) Number of edges much less then the vertices squared c) Adjacency Matrices – Memory Θ (V 2 ) i) Representation 1 – connection (could also be the distances / weights) 0 – no connection (could also be Integer.MAX_VALUE) ii) Better when there are a lot of extra connections 2) Search – both uninformed i) Lists save memory space at the cost of having to traverse the list to look up if a vertex is connected or not. Although we use a hash table, it is typically represented as a linked list, and has to be searched. The matrix on the other hand is a quicker, instant look-up, but at the cost of space. A lot of times it is best to use the list when the graph is sparse. A dense graph will begin to take up almost as much space as the matrix itself, so it is best handled by a matrix. ii)

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.

## This note was uploaded on 04/30/2008 for the course IE 170 taught by Professor Ralphs during the Spring '07 term at Lehigh University .

### Page1 / 2

Final Cheat Sheet - 1 Graphs i ii iii iv Undirected two way...

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

View Full Document
Ask a homework question - tutors are online