0% found this document useful (0 votes)
3 views

Algorithms

Uploaded by

Harsh Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Algorithms

Uploaded by

Harsh Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Algorithms 01

BY OHM PATEL
02 Brute Force Algorithms

What We'll Learn


Greedy Algorithms

Divide and Conquer Algorithms


It is an intuitive, direct, and
straightforward technique

All the possible ways or all the possible


solutions to a given problem are
enumerated

Brute Force Many problems solved in day-to-day life

Algorithm
using the brute force strategy, for example
exploring all the paths to a nearby market
to find the minimum shortest path.

Isn't the most efficient algorithm in


most cases.
The brute force approach is a PROS OF BRUTE
guaranteed way to find the
correct solution by listing all FORCE ALGORITHMS
the possible candidate
solutions for the problem.

It is a generic method and not


limited to any specific domain
of problems.

The brute force method is


ideal for solving small and
simpler problems.
The brute force approach is CONS OF BRUTE
inefficient. For real-time
problems, algorithm analysis FORCE ALGORITHMS
often goes above the O(N!)
order of growth.

This method relies more on


compromising the power of a
computer system for solving a
problem than on a good
algorithm design.

Brute force algorithms are


slow.
Brute Force Approach Example
Greedy is an algorithmic paradigm
that builds up a solution piece by
piece, always choosing the next
piece that offers the most obvious
and immediate benefit.

So the problems where choosing locally

Greedy Algorithms optimal also leads to global solution are


the best fit for Greedy.

Isn't the most efficient algorithm in


most cases.
The greedy approach is PROS OF GREEDY
easy to implement.
ALGORITHMS

Typically have less time


complexity.

Greedy algorithms can be used


for optimization purposes or
finding close to optimization in
case of Hard problems.
The local optimal solution may CONS OF GREEDY
not always be globally optimal.
ALGORITHMS

Prim’s Algorithm EXAMPLES OF GREEDY


Kruskal’s Algorithm
Dijkstra’s Algorithm ALGORITHMS
Greedy Approach Example
This technique can be divided into the
following three parts:
1. Divide: This involves dividing the
problem into smaller sub-problems.
2. Conquer: Solve sub-problems by calling

Divide and Conquer recursively until solved.


3. Combine: Combine the sub-problems to

Algorithms
get the final solution of the whole
problem.

Example of Divide and Conquer


algorithms:
1) Binary Search
2) MergeSort
3) QuickSort
It divides the entire PROS OF DAQ
problem into subproblems
thus it can be solved ALGORITHMS
parallelly ensuring
multiprocessing

The difficult problem can


be solved easily.

Reduces time complexity of


the problem
It involves recursion which is CONS OF DAQ
sometimes slow
ALGORITHMS

Efficiency depends on the


implementation of logic

It may crash the system if the


recursion is performed
rigorously
THANK YOU!

You might also like