ExamPreparation | QuizTime | LearningTools | Education | StudentSupport
CS 6515 final, CS 6515 Final, CS 6515 Final
Review Questions and Correct Answers the
Latest Update
Kite Reduction
✓ Prove Kite is in np by verifying that
✓ - check for the clique - O(n^2)
✓ - check for the tail of degree <= 2 nodes O(n)
✓ - check for that the tail is connected to the clique with Explore (O(n)
✓
✓ Reduce Clique to kite by adding a tail of length g to each vertex in graph G O(n^2)
✓
✓ Transform back to Clique by removing all vertexs of degree <= 2 (prune the tails)
✓
✓ If there is no solution to kite then there is no clique in G
✓ If there is a solution to kite, removing the tail is then a solution to clique
Common Subgraph
✓ Prove common subgraph is in NP by
✓ - Check that the remaining vertexs is > b (O(n) for each graph
✓ - Check that Graph G1' and G2' are identical O(nm)
✓
✓ Reduce Clique to Common Subgraph by
✓ - Creating a copy of G1 , G2 and connecting each vertex to each other vertex in
G2 . O(2)
✓ - Call Common Subgraph on G1, G2, and the same goal k
✓
✓ O(1) take G1 and provide that as the solution to clique if there is a common
subgraph.
✓
Smart Grades Latest update
1
,Examify | OnlineExams | TestPrep | StudyResources | AcademicSuccess |
ExamPreparation | QuizTime | LearningTools | Education | StudentSupport
✓ If there isnt a common subgraph to the clique we created G2 then G1 is not a
clique.
DFS
✓ Input : Graph G(V,E) directed or undirected
✓ Output : Prev[z] the parent index of vertex z
✓ pre[z] the pre number ""
✓ post[z] the post number ""
✓ ccum[z] the connected components
✓ can be strongly connected if verticies are passed in highest post number after
running dfs on a reversed directed graph
✓ Runtime: O(N+M)
Dijkstra's
✓ Input : Graph(V,E) directed or undirected
✓ Output :
✓ dist[u] the distance from s to u if s can reach u inf otherwise
✓ prev[z] the parent index of z
✓ non-negative weights
✓ O((n+m)logn) - adding weights adds work
BFS
✓ Input : Graph(V,E) directed or undirected , vertex s C V
✓ Output :
✓ dist[u] : the distance from s to u if s can reach u
✓ prev[z] : the parent index of vertex z
✓ O(n+M)
✓ - use this for unweighted single source shortest path
Smart Grades Latest update
1
, Examify | OnlineExams | TestPrep | StudyResources | AcademicSuccess |
ExamPreparation | QuizTime | LearningTools | Education | StudentSupport
Topological Sort
✓ Input : Graph G = (V,E), directed acyclic graph (DAG)
✓ Output :
✓ topo[i] : the vertex number of the i'th vertex in topological order from left to right,
source to sink
✓
✓ O(n+M)
✓ works by running DFS on the DAG and using the post order number to sort the
vertices from highest post to lowest post
Explore
✓ Input: Graph G = (V,E) , directed or undirected, v C V
✓ Output :
✓ visited[u] is set to true for all nodes u reachable from V
✓ - anything else available for DFS
✓
✓ O(m) as part of DFS
✓ O(n+m) if ran by itself and visited[] needs to be created
✓
✓ Subroutine of DFS
✓ Use this if you only care about a single source
✓ If you are to modify a black box algorithm, this would likely be the one
Strongly Connected Components
✓ Input : Graph G = (V,E), directed
✓ Output:
✓ GSCC = (V,E) where GSCC is a meta graph with each SCC in G forming a vertex C
V and each edge between SCCS C E
✓ VSSC will look like 1,2,3,4 which are ccums
✓ ESSC will look like (1,2) (2,3) (3,4) which are edges between VSSC
Smart Grades Latest update
1