0% found this document useful (0 votes)
7 views1 page

Micro 2

The document provides definitions and explanations of various graph-related concepts, including directed and undirected graphs, in-degree and out-degree, complete graphs, articulation points, and bridges. It also discusses algorithms such as Quick Sort and Merge Sort, along with the advantages and drawbacks of Dynamic Programming. Additionally, it compares Dijkstra's and Bellman-Ford algorithms in terms of their functionalities and complexities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Micro 2

The document provides definitions and explanations of various graph-related concepts, including directed and undirected graphs, in-degree and out-degree, complete graphs, articulation points, and bridges. It also discusses algorithms such as Quick Sort and Merge Sort, along with the advantages and drawbacks of Dynamic Programming. Additionally, it compares Dijkstra's and Bellman-Ford algorithms in terms of their functionalities and complexities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Here are definitions of the terms: Algorithm: Quick Sort Dynamic Programming (DP) is a powerful algorithmic paradigm

(i) Directed Graph Quick Sort is a divide-and-conquer algorithm for sorting an array. used for solving optimization and decision-making problems by
A directed graph, or digraph, is a type of graph in which the edges Here's the step-by-step process: breaking them down into smaller, overlapping subproblems. Here's
have a direction. Each edge is represented as an ordered pair (u,v), an analysis of its advantages and drawbacks:
where u is the starting vertex (source), and v is the ending vertex Steps of the Algorithm:
(destination). 1. Base Case: Advantages of Dynamic Programming
 The direction of the edge indicates the flow or If the array has zero or one element, it is already 1. Optimizes Recursive Problems:

relationship from u to v. sorted. o DP avoids redundant calculations by


2. Divide: storing the results of subproblems,
 Directed graphs can include loops (edges that Select a pivot element from the array. (Common making it much faster than naive
connect a vertex to itself). choices include the first element, last element, or a recursion for problems with
 Applications include representing tasks in a random element.) overlapping subproblems (e.g.,
workflow, web page links, and road networks where 3. Partition: Fibonacci sequence, knapsack
streets are one-way. Rearrange the elements in the array such that: problem).
o All elements smaller than the pivot 2. Systematic Approach:
(ii) Undirected Graph appear before the pivot. o DP provides a structured
An undirected graph is a type of graph in which the edges have no
direction. Each edge is represented as an unordered pair {u,v},
o All elements larger than the pivot methodology to solve problems. It
appear after the pivot. ensures that all possible subproblems
meaning there is no distinction between u and v The pivot is now in its correct are considered, which helps find an
 The edges indicate a mutual or bidirectional position.
3.
optimal solution.
Handles Complex Problems:
relationship between the vertices. 4. Conquer:
Recursively apply the Quick Sort algorithm to the o DP can efficiently solve problems with
 Undirected graphs can also include loops. subarrays to the left and right of the pivot. overlapping subproblems and optimal
 Applications include modeling social networks, Time Complexity: substructure (e.g., shortest paths,
computer networks, and road networks without  Best and Average Case: O(n log n)
resource allocation, scheduling).
one-way restrictions.
 Worst Case: O(n^2) (occurs when the pivot is
(iii) In-Degree and Out-Degree consistently the smallest or largest element). Drawbacks of Dynamic Programming:-
Space Complexity: 1. Space Complexity:
 In-Degree: In a directed graph, the in-degree of a O(log n) for recursion stack in the best/average case. o DP often requires large memory for
vertex is the number of edges directed toward that
storing intermediate results (e.g., 2D
vertex. For a vertex v, it counts the edges (u,v),
tables for problems like matrix chain
where u is any vertex.
Algorithm: Merge Sort multiplication), leading to high space
 Out-Degree: In a directed graph, the out-degree of a Merge Sort is a divide-and-conquer algorithm that divides an array complexity.
vertex is the number of edges directed away from into smaller subarrays, sorts them, and then merges them back 2. Performance with Large Input:
that vertex. For a vertex v, it counts the edges (v,u),
where u is any vertex.
into a sorted array.
 For problems involving very large input sizes or
dimensions, even polynomial-time complexity might
For undirected graphs, the concept of in-degree and out-degree Steps of the Algorithm:
become impractical.
does not apply; instead, the degree of a vertex is the number of 1. Divide:
3. Difficulty in Debugging:
edges connected to it. Split the array into two halves until each subarray
contains a single element (base case).  Debugging a DP implementation can be hard due to
(iv) Complete Graph 2. Conquer: its reliance on a series of dependent computations.
A complete graph is a type of graph where every pair of distinct Recursively sort each half.
vertices is connected by a unique edge. 3. Combine: When to Use Dynamic Programming
 In an undirected complete graph with n vertices,
Merge the sorted halves into a single sorted array. Dynamic programming is suitable when:

there are (n/2)=n(n−1)/2edges.


Time Complexity:
 The problem can be broken into overlapping

 In a directed complete graph with n vertices, there


 Best, Average, and Worst Case: O(n log n) subproblems.
are n(n−1)n(n-1)n(n−1) edges, since every vertex has
(Divide the array takes log n and merging takes
O(n)for each level).
 The solution to a problem can be constructed from
a directed edge to every other vertex. solutions to smaller subproblems (optimal
Space Complexity:
Complete graphs are denoted as Kn , where n represents the substructure).
number of vertices.  O(n)for temporary arrays used during merging.
 The brute-force approach is too slow or inefficient.
(v) Articulation Point
An articulation point (or cut vertex) in a graph is a vertex whose
Differences Between Dijkstra's Algorithm and Bellman-Ford Prim(G, s):
removal (along with its incident edges) increases the number of
Algorithm Initialize:
connected components in the graph.
Aspect Dijkstra's Algorithm Bellman-Ford Algorithm key[v] = ∞ for all v in V
 Articulation points are critical to the structure of the
Finds the shortest path
parent[v] = -1 for all v in V
graph because they serve as "connectors" between Finds the shortest key[s] = 0
from a single source to
different parts of the graph. path from a single MST = empty set
Purpose all other vertices, even
 They are useful in applications such as network
source to all other
vertices.
with negative weight
PriorityQueue = MinHeap()
reliability and vulnerability analysis. edges.
Insert (key[v], v) for all v in V into PriorityQueue
Does not work with Works with negative
(vi) Bridge Negative
negative weight weight edges but detects While PriorityQueue is not empty:
A bridge (or cut-edge) in a graph is an edge whose removal Weights
edges. negative weight cycles. u = ExtractMin(PriorityQueue)
increases the number of connected components in the graph.
Relaxes edges Add u to MST
 A bridge represents a critical connection between greedily (only once
Relaxes all edges up to
two parts of the graph. Relaxation V−1 times (v = number of For each neighbor v of u:
for the selected
vertices).
 vertex). If v is not in MST and weight(u, v) < key[v]:
Identifying bridges is important in scenarios such as key[v] = weight(u, v)
road networks, computer networks, and Faster for sparse Slower for larger graphs parent[v] = u
Complexity
infrastructure analysis. graphs. with many edges. Update v's priority in PriorityQueue
Cannot detect
Detects and reports
Optimality negative weight Return MST and the total weight
negative weight cycles.
cycles.
Uses a priority queue
Iteratively updates
Implementation (often implemented
distances for all edges.
with a min-heap).

You might also like