Prim’s MST for Adjacency List Representation | Greedy Algo-6

We recommend to read following two posts as a prerequisite of this post. 1. Greedy Algorithms | Set 5 (Prim’s Minimum Spanning Tree (MST)) 2.… Read More »

Prim’s Minimum Spanning Tree (MST) | Greedy Algo-5

We have discussed Kruskal’s algorithm for Minimum Spanning Tree. Like Kruskal’s algorithm, Prim’s algorithm is also a Greedy algorithm. It starts with an empty spanning tree. The… Read More »

Efficient Huffman Coding for Sorted Input | Greedy Algo-4

We recommend to read following post as a prerequisite for this. Greedy Algorithms | Set 3 (Huffman Coding) Time complexity of the algorithm discussed in… Read More »

Kruskal’s Minimum Spanning Tree Algorithm | Greedy Algo-2

What is Minimum Spanning Tree? Given a connected and undirected graph, a spanning tree of that graph is a subgraph that is a tree and… Read More »

Maximum Length Chain of Pairs | DP-20

You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) can… Read More »

Activity Selection Problem | Greedy Algo-1

Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate… Read More »

Coin Change | DP-7

Given a value N, if we want to make change for N cents, and we have infinite supply of each of S = { S1,… Read More »

Boruvka’s algorithm for Minimum Spanning Tree

Following two algorithms are generally taught for Minimum Spanning Tree (MST) problem. Prim’s algorithm Kruskal’s algorithm There is a third algorithm called Boruvka’s algorithm for… Read More »

Applications of Minimum Spanning Tree Problem

Minimum Spanning Tree (MST) problem: Given connected graph G with positive edge weights, find a min weight set of edges that connects all of the… Read More »

Program for array rotation

Write a function rotate(ar[], d, n) that rotates arr[] of size n by d elements. Rotation of the above array by 2 will make array… Read More »

Write a program to print all permutations of a given string

A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with… Read More »