# Category Archives: Greedy

## Program for Worst Fit algorithm in Memory ManagementMarch 6, 2017

Prerequisite : Partition allocation methods Worst Fit allocates a process to the partition which is largest sufficient among the freely available partitions available in the… Read More »

## Program for Best Fit algorithm in Memory Management

Prerequisite : Partition allocation methods Best fit allocates the process to a partition which is the smallest sufficient partition among the free available partitions. Example:… Read More »

## Program for First Fit algorithm in Memory ManagementMarch 4, 2017

Prerequisite : Partition Allocation Methods In the first fit, partition is allocated which is first sufficient from the top of Main Memory. Example : Input… Read More »

## Lexicographically smallest array after at-most K consecutive swapsMarch 3, 2017

Given an array arr[], find the lexicographically smallest array that can be obtained after performing at maximum of k consecutive swaps. For example:- Input: arr[]… Read More »

## Program for Shortest Job First (or SJF) scheduling | Set 1 (Non- preemptive)February 24, 2017

Shortest job first (SJF) or shortest job next, is a scheduling policy that selects the waiting process with the smallest execution time to execute next.… Read More »

## Max Flow Problem IntroductionFebruary 19, 2017

Maximum flow problems involve finding a feasible flow through a single-source, single-sink flow network that is maximum. Let’s take an image to explain how above… Read More »

## Reverse Delete Algorithm for Minimum Spanning TreeFebruary 18, 2017

Reverse Delete algorithm is closely related to Kruskal’s algorithm. In Kruskal’s algorithm what we do is : Sort edges by increasing order of their weights.… Read More »

## Paper Cut into Minimum Number of SquaresJanuary 10, 2017

Given a paper of size A x B. Task is to cut the paper into squares of any size. Find the minimum number of squares… Read More »

## Minimize the sum of product of two arrays with permutations allowedDecember 23, 2016

Given two arrays, A and B, of equal size n, the task is to find the minimum value of A[0] * B[0] + A[1] *… Read More »

## Find maximum sum possible equal sum of three stacksDecember 21, 2016

Given three stack of the positive numbers, the task is to find the possible equal maximum sum of the stacks with removal of top elements… Read More »

## Minimum sum of two numbers formed from digits of an arrayDecember 19, 2016

Given an array of digits (values are from 0 to 9), find the minimum possible sum of two numbers formed from digits of the array.… Read More »

## Maximize array sum after K negations | Set 2December 11, 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 »

## Minimum edges to reverse to make path from a source to a destinationNovember 11, 2016

Given a directed graph and a source node and destination node, we need to find how many edges we need to reverse in order to… Read More »

## Minimum Cost to cut a board into squaresNovember 8, 2016

A board of length m and width n is given, we need to break this board into m*n squares such that cost of breaking is… Read More »

## 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 »