# Category Archives: Greedy

## Maximize array sum after K negations | Set 1October 20, 2016

Given an array of size n and a number k. We must modify array K number of times. Here modify array means in each operation… Read More »

## Job Sequencing Problem | Set 2 (Using Disjoint Set)June 7, 2016

Given a set of n jobs where each job i has a deadline di >=1 and profit pi>=0. Only one job can be scheduled at… Read More »

## Find smallest number with given number of digits and sum of digitsJune 6, 2016

How to find the smallest number with given digit sum s and number of digits d? Examples : Input : s = 9, d =… Read More »

## Minimize the maximum difference between the heightsMay 18, 2016

Given heights of n towers and a value k. We need to either increase or decrease height of every tower by k (only once) where… Read More »

## Dial’s Algorithm (Optimized Dijkstra for small range weights)April 11, 2016

Dijkstra’s shortest path algorithm runs in O(Elog V) time when implemented with adjacency list representation (See C implementation and STL based C++ implementations for details).… Read More »

## Fractional Knapsack ProblemMarch 23, 2016

Given weights and values of n items, we need put these items in a knapsack of capacity W to get the maximum total value in… Read More »

## Bin Packing Problem (Minimize number of used Bins)March 3, 2016

Given n items of different weights and bins each of capacity c, assign each item to a bin such that number of total used bins… Read More »

## Find minimum time to finish all jobs with given constraintsOctober 4, 2015

Given an array of jobs with different time requirements. There are K identical assignees available and we are also given how much time an assignee… Read More »

## Greedy Algorithm to find Minimum number of CoinsAugust 19, 2015

Given a value V, if we want to make change for V Rs, and we have infinite supply of each of the denominations in Indian… Read More »

## Shortest Superstring ProblemJuly 4, 2015

Given a set of n strings arr[], find the smallest string that contains each string in the given set as substring. We may assume that… Read More »

## Greedy Algorithms | Set 9 (Boruvka’s algorithm)May 20, 2015

We have discussed following topics on Minimum Spanning Tree. Applications of Minimum Spanning Tree Problem Kruskal’s Minimum Spanning Tree Algorithm

## Set Cover Problem | Set 1 (Greedy Approximate Algorithm)March 27, 2015

Given a universe U of n elements, a collection of subsets of U say S = {S1, S2…,Sm} where every subset Si has an associated… Read More »

## K Centers Problem | Set 1 (Greedy Approximate Algorithm)March 26, 2015

Given n cities and distances between every pair of cities, select k cities to place warehouses (or ATMs or Cloud Server) such that the maximum… Read More »

## Greedy Algorithm for Egyptian FractionFebruary 4, 2015

Every positive fraction can be represented as sum of unique unit fractions. A fraction is unit fraction if numerator is 1 and denominator is a… Read More »

## Minimize Cash Flow among a given set of friends who have borrowed money from each otherJanuary 4, 2015

Given a number of friends who have to give or take some amount of money from one another. Design an algorithm by which the total… Read More »