Category Archives: Greedy

Program for Worst Fit algorithm in Memory Management

Prerequisite : Partition allocation methods Worst Fit allocates a process to the partition which is largest sufficient among the freely available partitions available in the main memory. If a large process comes at a later stage, then memory will not have space to accommodate it. Example: Input : blockSize[] = {100, 500, 200, 300, 600};… Read More »

Max Flow Problem Introduction

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 definition wants to say. Each edge is labeled with a capacity, the maximum amount of stuff that it can carry. The goal is to figure out how much stuff can… Read More »

Reverse Delete Algorithm for Minimum Spanning Tree

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. After sorting, we one by one pick edges in increasing order. We include current picked edge if by including this in spanning tree not form any cycle until there are… Read More »

Paper Cut into Minimum Number of Squares

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 that can be cut from the paper. Examples: Input : 13 x 29 Output : 9 Explanation : 2 (squares of size 13×13) + 4 (squares of size 3×3) +… Read More »