Final Cheat Sheet

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

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

View Full Document Right Arrow Icon
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)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online