Analysis & Design of Algorithms
Complete C programs, detailed explanations, complexity analysis, and viva questions for every VTU ADA Lab algorithm. Built for students, loved by developers.
#include<stdio.h>
#define MAX 10
int a[MAX][MAX], n, cost = 0;
void kruskal() {
int root[MAX], i, v1, v2;
for(i=1; i<=n; i++)
root[i] = i;
// Greedily pick min edges...
i = 0;
while(i != n-1) {
findmin(&v1, &v2);
if(root[v1] != root[v2])
update(root, v1, v2);
}
} #include<stdio.h>
int a[10][10], n, cost = 0;
void kruskal() {
// Greedily pick min weight edges
while(edges < n-1) {
findmin(&v1, &v2);
if(root[v1] != root[v2])
update(root, v1, v2);
}
} Featured Algorithms
Complete C programs with explanations and complexity analysis
Kruskal's Algorithm
Kruskal's algorithm finds the Minimum Spanning Tree of a weighted graph by sorting edges and using union-find to avoid cycles.
Prim's Algorithm
Prim's algorithm builds a Minimum Spanning Tree by greedily expanding from a starting vertex, always picking the minimum cost edge to an unvisited vertex.
Dijkstra's Algorithm
Dijkstra's algorithm finds the shortest path from a single source vertex to all other vertices in a weighted graph with non-negative edge weights.
Floyd's Algorithm
Floyd's algorithm (Floyd-Warshall) finds the shortest paths between all pairs of vertices in a weighted graph using dynamic programming.
Warshall's Algorithm
Warshall's algorithm computes the transitive closure of a directed graph — determining if a path exists between every pair of vertices.
Topological Sorting
Topological Sort linearly orders vertices of a Directed Acyclic Graph (DAG) such that for every directed edge u→v, vertex u comes before v.
Algorithm Categories
Organized by algorithmic paradigm
Greedy Algorithms
Make locally optimal choices at each step to find a global optimum
Dynamic Programming
Break problems into overlapping subproblems and store results
Divide and Conquer
Divide problem into subproblems, solve, and combine results
Backtracking
Explore all possibilities and undo bad choices
Graph Algorithms
Algorithms that operate on graph data structures
Complexity Cheat Sheet
Quick reference for all VTU ADA Lab algorithm complexities
| Algorithm | Best | Average | Worst | Space |
|---|---|---|---|---|
| Kruskal's MST | O(E log E) | O(E log E) | O(E log E) | O(V) |
| Prim's MST | O(V²) | O(V²) | O(V²) | O(V) |
| Dijkstra's SSSP | O(V²) | O(V²) | O(V²) | O(V) |
| Floyd-Warshall | O(V³) | O(V³) | O(V³) | O(V²) |
| Quick Sort | O(n log n) | O(n log n) | O(n²) | O(log n) |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) |
| N-Queens | O(N!) | O(N!) | O(N!) | O(N) |
| 0/1 Knapsack | O(nW) | O(nW) | O(nW) | O(nW) |
GitHub Repository
All source code is open-source and available on GitHub. Star the repository to stay updated with new programs and improvements.
About the Author
Passionate CS student building open-source educational resources for fellow students. This repository contains complete VTU ADA Lab programs with detailed explanations to help you ace your exams.
Latest Articles
Learn the theory behind the algorithms