Skip to main content

Maths 1 Week 11 Summary

📚

Graph Theory Summary

Directed Acyclic Graph (DAG)

A Directed Acyclic Graph (DAG) is a graph that is directed and contains no cycles. This means that it is impossible to start at any vertex and follow a sequence of edges that eventually loops back to the starting vertex.

Topological Sorting

Topological sorting of a DAG is a linear ordering of its vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering. This is useful for scheduling tasks, resolving symbol dependencies in linkers, etc.

Longest Path in DAG

Finding the longest path in a DAG can be done in linear time using topological sorting. Since DAGs have no cycles, the longest path problem is simpler compared to general graphs.

Shortest Path Algorithms

Shortest path algorithms are used to find the shortest path between vertices in a graph. Common algorithms include:

  • Dijkstra's Algorithm: Finds the shortest path from a single source vertex to all other vertices in a graph with non-negative edge weights.
  • Bellman-Ford Algorithm: Computes shortest paths from a single source vertex to all other vertices in a graph, even with negative edge weights. It can detect negative weight cycles.
  • Floyd-Warshall Algorithm: Finds shortest paths between all pairs of vertices in a graph. It uses dynamic programming and can handle negative weights but not negative cycles.

Dijkstra's Algorithm

Dijkstra's algorithm is a greedy algorithm that finds the shortest path from a source vertex to all other vertices in a graph with non-negative edge weights. It uses a priority queue to repeatedly select the vertex with the smallest distance and update the distances of its neighbors.

Bellman-Ford Algorithm

The Bellman-Ford algorithm computes shortest paths from a single source vertex to all other vertices in a graph, even if the graph has negative edge weights. It iteratively relaxes all edges and can detect negative weight cycles.

Floyd-Warshall Algorithm

The Floyd-Warshall algorithm finds shortest paths between all pairs of vertices in a graph. It uses a dynamic programming approach to iteratively improve the shortest path estimates by considering all possible paths through the graph.

Difference Between Bellman-Ford and Floyd-Warshall

While both algorithms can handle graphs with negative weights, they differ in their approach and use cases:

  • Bellman-Ford: Single-source shortest path algorithm, suitable for graphs with negative weights and capable of detecting negative cycles.
  • Floyd-Warshall: All-pairs shortest path algorithm, uses dynamic programming and is simpler to implement but less efficient for large graphs.

Minimum Cost Spanning Tree

A Minimum Spanning Tree (MST) of a graph is a subset of the edges that connects all vertices together, without any cycles and with the minimum possible total edge weight. Two common algorithms to find the MST are:

  • Kruskal's Algorithm: A greedy algorithm that sorts all edges by weight and adds them one by one to the MST, ensuring no cycles are formed.Prim's Algorithm: Another greedy algorithm that starts with a single vertex and grows the MST by adding the smallest edge that connects a vertex in the MST to a vertex outside the MST.

Kruskal's Algorithm

Kruskal's algorithm builds the MST by sorting all edges and adding them one by one, ensuring no cycles are formed. It uses a disjoint-set data structure to efficiently manage the connected components of the graph.

Prim's Algorithm

Prim's algorithm starts with a single vertex and grows the MST by repeatedly adding the smallest edge that connects a vertex in the MST to a vertex outside the MST. It is typically implemented using a priority queue.

Comments

Popular post

IITM Notes

Course Overview “These handwritten notes encompass topics in data science and civil services. The beauty of knowledge is that you don’t need to belong to any specific group; simply maintain your curiosity, and knowledge will find its way to you. I hope these notes are helpful. If they are, please consider leaving a comment below and follow my blog for updates.” Mathematics 1 👉 Select Week Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Week 8 Week 9 Week 10 Week 11 Revision Statistics 1 👉 Select Week Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Week 8 Week 9 Week 10 Week 11

Maths 1 week 1 Summary

Number System and Set Theory 📚 Number System and Set Theory This week, our teacher covered the basics of the number system. We were instructed to consider 0 as part of the natural numbers, as it will be treated as such in future subjects like Python. However, in exams, it will be explicitly stated whether 0 should be considered a natural number. The key topics from this week include set theory and the relationship between two sets. In set theory, we focused on three Venn diagram problems. In the context of relations, we discussed the concepts of reflexive, symmetric, transitive, and equivalence relations. Detailed Explanation 1.Union of Two Sets The union of two sets A and B is the set of elements that are in either A , B , or both. It is denoted as A ∪ B . 2.Intersection of Two Sets The intersection of two sets A and B is the set of elements that are in both A and B . It is denoted as A ∩ B . 3.Subt

Community page

Welcome To our IITM BS Students Community This community is a student commune where IIT Madras Bachelor of Science students are studying. Our community is managed by 15 community admins who oversee our WhatsApp community, Discord, and Telegram profiles. With more than 1000+ active members, we study together, share memes, watch movies, play games, and have fun. Our goal is to bring all online IITM students together to excel in exams while having fun. Community Admins Agampreet LinkedIn Ansh Ashwin Ambatwar Arti Dattu Dolly Elango Koushik Shrijanani Saksham Shivamani Shivam Instagram LinkedIn Join Our Community Subscribe to our YouTube page Join our meme team on