Skip to content

Category Archives: Greedy

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
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
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
Given an array of jobs where every job has a deadline and associated profit if the job is finished before the deadline. It is also… Read More
Given the arrival and departure times of all trains that reach a railway station, the task is to find the minimum number of platforms required… Read More
MakeMyTrip recently visited our campus. Below is my interview experience:  Round 1: (Online MCQs) Section A- There were 20 Aptitude and Logical Reasoning questions which has… Read More
There are given n ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal… Read More
Given a string and a positive integer d. Some characters may be repeated in the given string. Rearrange characters of the given string such that… Read More
We introduced graph coloring and applications in previous post. As discussed in the previous post, graph coloring is widely used. Unfortunately, there is no efficient… Read More
We recommend reading the following two posts as a prerequisite of this post.1. Greedy Algorithms | Set 7 (Dijkstra’s shortest path algorithm) 2. Graph and its representationsWe… Read More
  Given a graph and a source vertex in the graph, find the shortest paths from the source to all vertices in the given graph.Dijkstra’s… Read More
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. Graph and… Read More
  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.… Read More
We recommend to read following post as a prerequisite for this.Greedy Algorithms | Set 3 (Huffman Coding) Time complexity of the algorithm discussed in above… Read More
Huffman coding is a lossless data compression algorithm. The idea is to assign variable-length codes to input characters, lengths of the assigned codes are based… Read More