discrete 2
discrete 2
3. b) There must be a path between every pair of vertices, but not necessarily a direct
edge.
6. In a bipartite graph, how can you divide the vertices into two disjoint sets?
a) Each vertex in one set is connected to exactly one vertex in the other set.
b) The vertices can be divided such that there is no edge between vertices within the same
set.
d) Each vertex in one set is connected to every vertex in the other set.
7. Which algorithm is typically used to find the shortest path from a source vertex
to all other vertices in a weighted graph?
a) Kruskal’s algorithm
b) Dijkstra’s algorithm
c) Depth-first search
d) Floyd-Warshall algorithm
8. What is the degree of a vertex in a graph?
a) 1
b) 2
c) 3
d) 5
11. Which of the following algorithms is used to find the Minimum Spanning Tree
(MST) of a weighted graph?
a) Dijkstra’s algorithm
b) Prim’s algorithm
c) Bellman-Ford algorithm
d) Floyd-Warshall algorithm
12. A directed acyclic graph (DAG) is often used to model which of the following?
a) Peer-to-peer networks
13. In a graph, a Hamiltonian path visits each vertex exactly once. Which of the
following is true about a graph that contains a Hamiltonian cycle?
11. Define a graph and explain the difference between a directed and an undirected
graph. Provide an example of each.
a. A set of vertices and edges, directed is one vertice toanother while
undirected can be a to b or b to a
12. What is a bipartite graph? How can you determine if a graph is bipartite?
a. Evr vertice is mapped to one vertice
13. Explain the difference between an Eulerian path and a Hamiltonian path. How
do you determine if a graph has each type of path?
a. Eulerian visit ever edge and hamilonian visit every vertice regradless of
path
14. Describe the process of finding the Minimum Spanning Tree (MST) using Prim’s
algorithm. Provide a simple example.
a. Compare each edge that can be tattken total weight with each other
15. What is a cut in a graph, and what is the significance of a minimum cut in the
context of network flow?
a.
16. **Given the graph GG with vertices V={A,B,C,D,E}V = \{A, B, C, D, E\} and edges:
• (A, B) = 3,
• (A, C) = 1,
• (B, D) = 2,
• (C, D) = 4,
• (D, E) = 5,
• (C, E) = 6,
• (B, E) = 7.
Use Kruskal’s algorithm to find the Minimum Spanning Tree (MST) of the graph. Show the
steps and the edges selected.**
17. **You are given the following directed graph:
• (1 → 2),
• (2 → 3),
• (3 → 4),
• (4 → 2).
(a) Determine if this graph contains a cycle.
(b) If it does, describe how to detect the cycle.**
18. **Given the following graph with 6 vertices and the following edges:
• (1, 2), (1, 3), (2, 3), (3, 4), (4, 5), (5, 6), (6, 2).
(a) Draw the graph.
(b) Is the graph strongly connected? Justify your answer.**
19. **Consider a graph with the following edge list:
• (1, 2), (1, 3), (1, 4), (2, 5), (3, 5), (4, 5), (5, 6).
(a) Find the degree of each vertex.
(b) Determine if the graph is connected or disconnected.**
20. **In a weighted graph, apply Dijkstra’s algorithm to find the shortest path from
vertex 1 to all other vertices. Show the steps with the given edges:
• (1, 2) = 7,
• (1, 3) = 9,
• (2, 3) = 3,
• (2, 4) = 5,
• (3, 4) = 2,
• (3, 5) = 7,
• (4, 5) = 4.**
21. **You are given a directed graph GG with 5 vertices and the following edges:
• (1 → 2),
• (2 → 3),
• (3 → 4),
• (4 → 5),
• (5 → 1).
(a) Determine if this graph has a strongly connected component.
(b) If it does, find the strongly connected components and explain your reasoning.**
22. **Consider the following graph:
• (1, 2) = 5,
• (1, 3) = 2,
• (2, 3) = 1,
• (2, 4) = 3,
• (3, 4) = 7,
• (4, 5) = 6,
• (3, 5) = 4.
(a) Use Bellman-Ford algorithm to find the shortest path from vertex 1 to all other
vertices.
(b) Explain how the algorithm handles negative weights and provide a simple example.**
23. **You are tasked with finding the maximum flow in a flow network with the
following graph:
• SS → AA: 10,
• SS → BB: 5,
• AA → BB: 15,
• AA → TT: 10,
• BB → TT: 10.
Apply Ford-Fulkerson algorithm to find the maximum flow from SS to TT. Show the steps
and the maximum flow value.**
Solution Key
1. b) There must be a path between every pair of vertices, but not necessarily a direct
edge.
2. b) The vertices can be divided such that there is no edge between vertices within the
same set.
3. b) Dijkstra’s algorithm
4. a) The number of edges connected to the vertex.
5. b) Every vertex in the graph must have an even degree.
6. d) 5
7. b) Prim’s algorithm
8. b) Task scheduling with dependencies
9. a) The graph must be connected.
10. b) It is connected and acyclic.
End of Exam