Python Program to Find the Roots of a Quadratic Equation

This is a Python Program to find the roots of an equation. Problem Description The program takes the coefficients of an equation and finds the roots of the equation. Problem Solution 1. Take in the coefficients of the equation and store it in three separate variables. 2. Find the value of the discriminant, d. 3. … Read more

advertisement

Python Program to Print All Permutations of a String in Lexicographic Order using Recursion

This is a Python program to print all permutations of a string in lexicographic order using recursion. Problem Description The problem is the display all permutations of a string in lexicographic or dictionary order. Problem Solution 1. The algorithm work by creating a recursive function get_next_permutation that returns the next higher permutation of a sequence … Read more

advertisement

Python Program to Print All Permutations of a String in Lexicographic Order without Recursion

This is a Python program to print all permutations of a string in lexicographic order without using recursion. Problem Description The problem is the display all permutations of a string in lexicographic or dictionary order. Problem Solution 1. The algorithm work by first creating a loop that will run n! times where n is the … Read more

advertisement

Python Program to Minimize Lateness using Greedy Algorithm

This is a Python program to minimize maximum lateness using greedy algorithm. Problem Description We are given n requests numbered 0 to n – 1. Each request i has a time that it takes to complete t(i) and a deadline d(i). If a request i starts at time s(i), then its finish time is f(i) … Read more

advertisement

Python Program to Find the Smallest Set of Unit-Length Closed Intervals using Greedy Algorithm

This is a Python program to find smallest set of unit-length closed intervals that contains all points using greedy algorithm. Problem Description We are given a set of points on the x-axis. We have to find the minimum number of closed intervals of length 1 that will contain all of these points. Problem Solution 1. … Read more

advertisement

Python Program to Solve Interval Scheduling Problem using Greedy Algorithm

This is a Python program to solve the interval scheduling problem using greedy algorithm. Problem Description In the interval scheduling problem, we are given n activities numbered 0 to n – 1. Each activity i has a start time s(i) and a finish time f(i). Two activities i and j are mutually compatible if s(i) … Read more

advertisement

Python Program to Solve Fractional Knapsack Problem using Greedy Algorithm

This is a Python program to solve the fractional knapsack problem using greedy algorithm. Problem Description In the fractional knapsack problem, we are given a set of n items. Each item i has a value v(i) and a weight w(i) where 0 <= i < n. We are given a maximum weight W. The problem … Read more

advertisement

Python Program to Count all Paths in a Grid with Holes using Dynamic Programming with Bottom-Up Approach

This is a Python program to count all paths in an m x n grid with holes using dynamic programming with bottom-up approach. Problem Description We are given an m x n grid, i.e. a grid with m rows and n columns. We are also given a list of holes that the grid has. Each … Read more

advertisement

Python Program to Count All Paths in a Grid with Holes using Dynamic Programming with Memoization

This is a Python program to count all paths in an m x n grid with holes using dynamic programming with memoization. Problem Description We are given an m x n grid, i.e. a grid with m rows and n columns. We are also given a list of holes that the grid has. Each hole … Read more

advertisement

Python Program to Solve 0-1 Knapsack Problem using Dynamic Programming with Memoization

This is a Python program to solve the 0-1 knapsack problem using dynamic programming with top-down approach or memoization. Problem Description In the 0-1 knapsack problem, we are given a set of n items. For each item i, it has a value v(i) and a weight w(i) where 1

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.