Data Analysis and Algorithms Lecture 1: Introduction

Design and Analysis of
Algorithms
Course Outline
1. Introduction to Algorithms
2. Mathematical Preliminaries
3. Growth Functions
4. Recurrences
5. Overview of Data Structures
6. Sorting and Searching Algorithms
7. Tree Algorithms
8. Graph Algorithms
9. Strings and Pattern Matching
10. Dynamic Programming
11. Theory of NP-Completeness
Reference Books
1. T. Corman, E. Leiserson, L. Rivest, C. Stein, Introduction to
Algorithms, 3rd Edition, Prentice Hall
2. R. Sedgewik, P. Flajolet, An Introduction to the Analysis of
Algorithms, 2nd Edition, Addison-Wesley
3. A. Levitin, Introduction to Design and Analysis of Algorithms, 3rd
Edition, Pearson Education Inc
Introduction to Algorithms
Algorithms - History
• Procedures for solving geometric and arithmetic problems were formulated by ancient
Greeks.
• Some two thousands years ago, the celebrated procedure for finding greatest
common divisor (g c d) was discovered by Euclid.
• In tenth century, Persian mathematician Muhammad- inbne- Musa Al lkowarzimi
stated procedures for solving algebraic equations. The procedure are described in his
famous book Kitab al Jabr wa’l muqabla (‘Rules of restoring and equating’).
The word algorithm is coined from Alkhowarizm
• In the mid- twentieth century D.E. Knuth undertook in depth study and analysis of
algorithms. His work is embodied in the comprehensive book ‘Art of Computer
Programming’, which serves as foundation for modern study of algorithms.
Algorithms – Formal Definition
An algorithm is an orderly step-by-step procedure, which has the
characteristics:
1) It accepts one or more input value
2) It returns at least one output value
3) It terminates after finite steps
Algorithms – Applications
• Sorting Algorithms (Elementary and Advanced)
• Searching Algorithms (Linear and Non-linear)
• Strings Processing ( Pattern matching, Parsing, Compression,
Cryptography)
• Image Processing ( Compression, Matching, Conversion)
• Mathematical Algorithms (Random number generator, matrix
operations, FFT, etc)
Algorithms – Classic Problems
• Hamiltonian Circuit Problem
• Traveling Salesperson Problem
• Graph Coloring Problem
• The Sum-Set Problem
• The n-Queen Problem
Hamiltonian Circuit Problem
Problem: Determine if a given graph has a Hamiltonian circuit.
• A Hamiltonian circuit , also called tour, is path that starts and ends at
the same vertex, and passes through all other vertices exactly once.
• A graph can have more than one Hamiltonian circuit, or none at all.
Traveling Salesperson Problem
Problem(a): A salesperson has to travel to n cities, such he starts at one city
and ends up at the same city, visits each city exactly once , and covers
minimum distance.
Problem(b): Determine minimum tour for a graph with n vertices.
Graph Coloring Problem
• Problem :. For given graph, find the minimum number of colors that can be
used to color the vertices so that no two adjacent vertices have the same
color.
Graph Coloring Problem
• Problem :. For given graph, find the minimum number of colors that can be
used to color the vertices so that no two adjacent vertices have the same
color.
Sum of Subset Problem
Problem : Given a set of set S = {s1, s2, s3, … sn} of n positive integers and an
integer w, find all subsets of S such that sum of integers, in each subset, equals
w.
Suppose S = {s1, s2, s3, s4, s5}
Let s1=5, s2 = 6, s3 = 10, s4 = 11 ,s5 = 16, and w = 21
• s3 + s4 = 10 + 11 = 21
In general, for a set of n integers, there are 2n subsets need to be examined.
For example, for n=20, the number of subsets is 220 = 1,048,576
Sum of Subset Problem
Problem : Given a set of set S = {s1, s2, s3, … sn} of n positive integers and an
integer w, find all subsets of S such that sum of integers, in each subset, equals
w.
Suppose S = {s1, s2, s3, s4, s5}
Let s1=5, s2 = 6, s3 = 10, s4 = 11 ,s5 = 16, and w = 21
• s1 + s2 + s3 = 5 + 6 + 10 =21
• s1 + s5 = 5 + 16 = 21
• s3 + s4 = 10 + 11 = 21
In general, for a set of n integers, there are 2n subsets need to be examined.
For example, for n=20, the number of subsets is 220 = 1,048,576
n-Queen Problem
Problem : n queens are to be placed on an n by n chessboard so that no two
queens threat each other. A queen threats another queen if is on the same row,
or same column, or same diagonal of the chess board.
Algorithm Design
• Divide-and-Conquer Algorithm
• Greedy Algorithm
• Backtracking Algorithm
• Dynamic Programming
• Brute Force
• Approximation Algorithm
• Randomized Algorithm
Divide-and-Conquer Algorithm
The divide and conquer algorithm has the following approach:
1) The problem is split (divided) into two distinct independent sub problems
2) The sub problems are solved (conquered) separately
3) The solutions to the sub problems are merged together to obtain solution to
main problem.
Divide-and-Conquer Algorithm
Problem: Sort the set of numbers {25,10, 8, 45, 67, 33, 20, 59} in ascending
order.
Divide-and-Conquer Algorithm
• Quick Sort
• Merge Sort
• Binary Search
• Multiplication of Large Integers
• Matrix Multiplication
• Fast Fourier Transform
Divide-and-Conquer Algorithm
Divide and conquer algorithm provides efficient sorting and searching methods.
It, however, has following limitations:
• The divide-and-conquer algorithm is implemented using recursive function
calls, which is not supported by some of the programming languages.
• Recursive calls need large stacks to store intermediate results, utilize
computer’s special memory called heap which may not be available on some
systems and decrease data access speed
• The divide-and-conquer algorithm is in-efficient when sub problems are not
of nearly equal size.
Greedy Algorithm
Greedy Algorithm is designed to solve optimization problems. The greedy algorithm
has the follows approach:
1) The problem is solved in steps. At each step, several choices are available for
partial solutions. A greedy choice is made by selecting the option with maximum
( or minimum) cost. This is referred to as locally optimum solution, as opposed
to globally optimum solution, which is expected to be the overall optimum
solution.
2) It is checked if the selected option satisfies problems constraint ( for example, the
cost does not exceed the prescribed limit ).This is referred to as feasible solution.
3) If current solution is not feasible, the next best option is selected.
4) Once a choice is made, it is not changed in subsequent steps. This condition is
referred to as irrevocability
Greedy Algorithm
Problem: ATM is to deliver a change for Rs. 98, with minimum number of
currency notes/coins.
Greedy Algorithm
Minimum Cabling in network
• Prim’s Algorithm
• Kruskal’s Algorithm
Shortest route in a network
• Dijkstara Algorithm
Huffman coding for text compression
Optimum Job Scheduling
Greedy Algorithm
The greedy algorithm provides is a simple and elegant solution to optimization
problems. It has, however, the following limitations:
• The greedy algorithm does not always produce a globally optimum solution ,
(for example, in case of traveling salesperson problem).
• In order to check whether or not the resulting solution is optimal, further
analysis is required.
• Often the analysis for globally optimum solution is quite complex.
• Analysis may requires additional resources.
1 de 24

Recomendados

Solution of N Queens Problem genetic algorithm por
Solution of N Queens Problem genetic algorithm  Solution of N Queens Problem genetic algorithm
Solution of N Queens Problem genetic algorithm MohammedAlKazal
1.2K vistas17 diapositivas
Matrix Algebra : Mathematics for Business por
Matrix Algebra : Mathematics for BusinessMatrix Algebra : Mathematics for Business
Matrix Algebra : Mathematics for BusinessKhan Tanjeel Ahmed
7.8K vistas66 diapositivas
Triangularization method por
Triangularization methodTriangularization method
Triangularization methodKamran Ansari
11K vistas10 diapositivas
Sudoku por
SudokuSudoku
SudokuYara Ali
2.9K vistas48 diapositivas
Matrix presentation By DHEERAJ KATARIA por
Matrix presentation By DHEERAJ KATARIAMatrix presentation By DHEERAJ KATARIA
Matrix presentation By DHEERAJ KATARIADheeraj Kataria
2.2K vistas113 diapositivas
Ppt presentasi matrix algebra por
Ppt presentasi matrix algebraPpt presentasi matrix algebra
Ppt presentasi matrix algebraRahmatulFitri1
137 vistas10 diapositivas

Más contenido relacionado

La actualidad más candente

Bba i-bm-u-2- matrix - por
Bba i-bm-u-2- matrix -Bba i-bm-u-2- matrix -
Bba i-bm-u-2- matrix -Rai University
10.6K vistas42 diapositivas
MATRICES por
MATRICESMATRICES
MATRICESdaferro
2.3K vistas12 diapositivas
System of linear algebriac equations nsm por
System of linear algebriac equations nsmSystem of linear algebriac equations nsm
System of linear algebriac equations nsmRahul Narang
543 vistas18 diapositivas
Matrix algebra por
Matrix algebraMatrix algebra
Matrix algebraFarzad Javidanrad
17.8K vistas39 diapositivas
matricesMrtices por
matricesMrticesmatricesMrtices
matricesMrticesYourskill Tricks
394 vistas18 diapositivas
Chapter 4: Linear Algebraic Equations por
Chapter 4: Linear Algebraic EquationsChapter 4: Linear Algebraic Equations
Chapter 4: Linear Algebraic EquationsMaria Fernanda
2K vistas37 diapositivas

La actualidad más candente(19)

Bba i-bm-u-2- matrix - por Rai University
Bba i-bm-u-2- matrix -Bba i-bm-u-2- matrix -
Bba i-bm-u-2- matrix -
Rai University10.6K vistas
MATRICES por daferro
MATRICESMATRICES
MATRICES
daferro2.3K vistas
System of linear algebriac equations nsm por Rahul Narang
System of linear algebriac equations nsmSystem of linear algebriac equations nsm
System of linear algebriac equations nsm
Rahul Narang543 vistas
Chapter 4: Linear Algebraic Equations por Maria Fernanda
Chapter 4: Linear Algebraic EquationsChapter 4: Linear Algebraic Equations
Chapter 4: Linear Algebraic Equations
Maria Fernanda 2K vistas
Matrix chain multiplication por Respa Peter
Matrix chain multiplicationMatrix chain multiplication
Matrix chain multiplication
Respa Peter33.8K vistas
Lecture 5 inverse of matrices - section 2-2 and 2-3 por njit-ronbrown
Lecture 5   inverse of matrices - section 2-2 and 2-3Lecture 5   inverse of matrices - section 2-2 and 2-3
Lecture 5 inverse of matrices - section 2-2 and 2-3
njit-ronbrown8.2K vistas
Matrices ppt por aakashray33
Matrices pptMatrices ppt
Matrices ppt
aakashray333.4K vistas
Parametric versus semi nonparametric parametric regression models por Nuriye Sancar
Parametric versus semi nonparametric parametric regression modelsParametric versus semi nonparametric parametric regression models
Parametric versus semi nonparametric parametric regression models
Nuriye Sancar898 vistas
Direct Methods For The Solution Of Systems Of por Marcela Carrillo
Direct Methods For The Solution Of Systems OfDirect Methods For The Solution Of Systems Of
Direct Methods For The Solution Of Systems Of
Marcela Carrillo1.1K vistas
Matrices and determinants por som allul
Matrices and determinantsMatrices and determinants
Matrices and determinants
som allul6.2K vistas
Linear inequalities in two variables por christianjustine
Linear inequalities in two variablesLinear inequalities in two variables
Linear inequalities in two variables
christianjustine5.5K vistas
Matrices por NORAIMA
MatricesMatrices
Matrices
NORAIMA2.2K vistas

Similar a Data Analysis and Algorithms Lecture 1: Introduction

Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER por
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERmuthukrishnavinayaga
1.4K vistas59 diapositivas
Undecidable Problems and Approximation Algorithms por
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation AlgorithmsMuthu Vinayagam
140 vistas61 diapositivas
BackTracking Algorithm: Technique and Examples por
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and ExamplesFahim Ferdous
45K vistas30 diapositivas
Back tracking por
Back trackingBack tracking
Back trackingKeshav Memorial Institute of Technology
132 vistas30 diapositivas
Chapter 5.pptx por
Chapter 5.pptxChapter 5.pptx
Chapter 5.pptxTekle12
5 vistas40 diapositivas

Similar a Data Analysis and Algorithms Lecture 1: Introduction(20)

Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER por muthukrishnavinayaga
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWERUndecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
muthukrishnavinayaga1.4K vistas
Undecidable Problems and Approximation Algorithms por Muthu Vinayagam
Undecidable Problems and Approximation AlgorithmsUndecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
Muthu Vinayagam140 vistas
BackTracking Algorithm: Technique and Examples por Fahim Ferdous
BackTracking Algorithm: Technique and ExamplesBackTracking Algorithm: Technique and Examples
BackTracking Algorithm: Technique and Examples
Fahim Ferdous45K vistas
Chapter 5.pptx por Tekle12
Chapter 5.pptxChapter 5.pptx
Chapter 5.pptx
Tekle125 vistas
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx por B.T.L.I.T
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptxbcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
bcfbedbf-6679-4d5d-b8a5-7d4c9c48dba4.pptx
B.T.L.I.T12 vistas
DAA ppt.pptx por RAJESH S
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptx
RAJESH S18 vistas
DAA 1 ppt.pptx por RAJESH S
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptx
RAJESH S14 vistas
Sienna 1 intro por chidabdu
Sienna 1 introSienna 1 intro
Sienna 1 intro
chidabdu438 vistas
unit-4-dynamic programming por hodcsencet
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
hodcsencet378 vistas
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's por Jay Patel
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal'sGreedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Greedy algorithms -Making change-Knapsack-Prim's-Kruskal's
Jay Patel3.1K vistas
Constraint satisfaction problems (csp) por Archana432045
Constraint satisfaction problems (csp)   Constraint satisfaction problems (csp)
Constraint satisfaction problems (csp)
Archana432045465 vistas
Computability and Complexity por Edward Blurock
Computability and ComplexityComputability and Complexity
Computability and Complexity
Edward Blurock2.2K vistas
Crout s method for solving system of linear equations por Sugathan Velloth
Crout s method for solving system of linear equationsCrout s method for solving system of linear equations
Crout s method for solving system of linear equations
Sugathan Velloth20.2K vistas

Último

Monthly Information Session for MV Asterix (November) por
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)Esquimalt MFRC
58 vistas26 diapositivas
11.30.23 Poverty and Inequality in America.pptx por
11.30.23 Poverty and Inequality in America.pptx11.30.23 Poverty and Inequality in America.pptx
11.30.23 Poverty and Inequality in America.pptxmary850239
167 vistas33 diapositivas
CONTENTS.pptx por
CONTENTS.pptxCONTENTS.pptx
CONTENTS.pptxiguerendiain
57 vistas17 diapositivas
ACTIVITY BOOK key water sports.pptx por
ACTIVITY BOOK key water sports.pptxACTIVITY BOOK key water sports.pptx
ACTIVITY BOOK key water sports.pptxMar Caston Palacio
745 vistas4 diapositivas
Google solution challenge..pptx por
Google solution challenge..pptxGoogle solution challenge..pptx
Google solution challenge..pptxChitreshGyanani1
135 vistas18 diapositivas
CUNY IT Picciano.pptx por
CUNY IT Picciano.pptxCUNY IT Picciano.pptx
CUNY IT Picciano.pptxapicciano
54 vistas17 diapositivas

Último(20)

Monthly Information Session for MV Asterix (November) por Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC58 vistas
11.30.23 Poverty and Inequality in America.pptx por mary850239
11.30.23 Poverty and Inequality in America.pptx11.30.23 Poverty and Inequality in America.pptx
11.30.23 Poverty and Inequality in America.pptx
mary850239167 vistas
CUNY IT Picciano.pptx por apicciano
CUNY IT Picciano.pptxCUNY IT Picciano.pptx
CUNY IT Picciano.pptx
apicciano54 vistas
Use of Probiotics in Aquaculture.pptx por AKSHAY MANDAL
Use of Probiotics in Aquaculture.pptxUse of Probiotics in Aquaculture.pptx
Use of Probiotics in Aquaculture.pptx
AKSHAY MANDAL104 vistas
7 NOVEL DRUG DELIVERY SYSTEM.pptx por Sachin Nitave
7 NOVEL DRUG DELIVERY SYSTEM.pptx7 NOVEL DRUG DELIVERY SYSTEM.pptx
7 NOVEL DRUG DELIVERY SYSTEM.pptx
Sachin Nitave61 vistas
Ch. 8 Political Party and Party System.pptx por Rommel Regala
Ch. 8 Political Party and Party System.pptxCh. 8 Political Party and Party System.pptx
Ch. 8 Political Party and Party System.pptx
Rommel Regala53 vistas
Structure and Functions of Cell.pdf por Nithya Murugan
Structure and Functions of Cell.pdfStructure and Functions of Cell.pdf
Structure and Functions of Cell.pdf
Nithya Murugan701 vistas
On Killing a Tree.pptx por AncyTEnglish
On Killing a Tree.pptxOn Killing a Tree.pptx
On Killing a Tree.pptx
AncyTEnglish66 vistas
How to empty an One2many field in Odoo por Celine George
How to empty an One2many field in OdooHow to empty an One2many field in Odoo
How to empty an One2many field in Odoo
Celine George72 vistas
The Accursed House by Émile Gaboriau por DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta212 vistas
Narration lesson plan por TARIQ KHAN
Narration lesson planNarration lesson plan
Narration lesson plan
TARIQ KHAN59 vistas
AUDIENCE - BANDURA.pptx por iammrhaywood
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptx
iammrhaywood89 vistas
Classification of crude drugs.pptx por GayatriPatra14
Classification of crude drugs.pptxClassification of crude drugs.pptx
Classification of crude drugs.pptx
GayatriPatra1492 vistas
Psychology KS5 por WestHatch
Psychology KS5Psychology KS5
Psychology KS5
WestHatch103 vistas
Dance KS5 Breakdown por WestHatch
Dance KS5 BreakdownDance KS5 Breakdown
Dance KS5 Breakdown
WestHatch86 vistas

Data Analysis and Algorithms Lecture 1: Introduction

  • 1. Design and Analysis of Algorithms
  • 2. Course Outline 1. Introduction to Algorithms 2. Mathematical Preliminaries 3. Growth Functions 4. Recurrences 5. Overview of Data Structures 6. Sorting and Searching Algorithms 7. Tree Algorithms 8. Graph Algorithms 9. Strings and Pattern Matching 10. Dynamic Programming 11. Theory of NP-Completeness
  • 3. Reference Books 1. T. Corman, E. Leiserson, L. Rivest, C. Stein, Introduction to Algorithms, 3rd Edition, Prentice Hall 2. R. Sedgewik, P. Flajolet, An Introduction to the Analysis of Algorithms, 2nd Edition, Addison-Wesley 3. A. Levitin, Introduction to Design and Analysis of Algorithms, 3rd Edition, Pearson Education Inc
  • 5. Algorithms - History • Procedures for solving geometric and arithmetic problems were formulated by ancient Greeks. • Some two thousands years ago, the celebrated procedure for finding greatest common divisor (g c d) was discovered by Euclid. • In tenth century, Persian mathematician Muhammad- inbne- Musa Al lkowarzimi stated procedures for solving algebraic equations. The procedure are described in his famous book Kitab al Jabr wa’l muqabla (‘Rules of restoring and equating’). The word algorithm is coined from Alkhowarizm • In the mid- twentieth century D.E. Knuth undertook in depth study and analysis of algorithms. His work is embodied in the comprehensive book ‘Art of Computer Programming’, which serves as foundation for modern study of algorithms.
  • 6. Algorithms – Formal Definition An algorithm is an orderly step-by-step procedure, which has the characteristics: 1) It accepts one or more input value 2) It returns at least one output value 3) It terminates after finite steps
  • 7. Algorithms – Applications • Sorting Algorithms (Elementary and Advanced) • Searching Algorithms (Linear and Non-linear) • Strings Processing ( Pattern matching, Parsing, Compression, Cryptography) • Image Processing ( Compression, Matching, Conversion) • Mathematical Algorithms (Random number generator, matrix operations, FFT, etc)
  • 8. Algorithms – Classic Problems • Hamiltonian Circuit Problem • Traveling Salesperson Problem • Graph Coloring Problem • The Sum-Set Problem • The n-Queen Problem
  • 9. Hamiltonian Circuit Problem Problem: Determine if a given graph has a Hamiltonian circuit. • A Hamiltonian circuit , also called tour, is path that starts and ends at the same vertex, and passes through all other vertices exactly once. • A graph can have more than one Hamiltonian circuit, or none at all.
  • 10. Traveling Salesperson Problem Problem(a): A salesperson has to travel to n cities, such he starts at one city and ends up at the same city, visits each city exactly once , and covers minimum distance. Problem(b): Determine minimum tour for a graph with n vertices.
  • 11. Graph Coloring Problem • Problem :. For given graph, find the minimum number of colors that can be used to color the vertices so that no two adjacent vertices have the same color.
  • 12. Graph Coloring Problem • Problem :. For given graph, find the minimum number of colors that can be used to color the vertices so that no two adjacent vertices have the same color.
  • 13. Sum of Subset Problem Problem : Given a set of set S = {s1, s2, s3, … sn} of n positive integers and an integer w, find all subsets of S such that sum of integers, in each subset, equals w. Suppose S = {s1, s2, s3, s4, s5} Let s1=5, s2 = 6, s3 = 10, s4 = 11 ,s5 = 16, and w = 21 • s3 + s4 = 10 + 11 = 21 In general, for a set of n integers, there are 2n subsets need to be examined. For example, for n=20, the number of subsets is 220 = 1,048,576
  • 14. Sum of Subset Problem Problem : Given a set of set S = {s1, s2, s3, … sn} of n positive integers and an integer w, find all subsets of S such that sum of integers, in each subset, equals w. Suppose S = {s1, s2, s3, s4, s5} Let s1=5, s2 = 6, s3 = 10, s4 = 11 ,s5 = 16, and w = 21 • s1 + s2 + s3 = 5 + 6 + 10 =21 • s1 + s5 = 5 + 16 = 21 • s3 + s4 = 10 + 11 = 21 In general, for a set of n integers, there are 2n subsets need to be examined. For example, for n=20, the number of subsets is 220 = 1,048,576
  • 15. n-Queen Problem Problem : n queens are to be placed on an n by n chessboard so that no two queens threat each other. A queen threats another queen if is on the same row, or same column, or same diagonal of the chess board.
  • 16. Algorithm Design • Divide-and-Conquer Algorithm • Greedy Algorithm • Backtracking Algorithm • Dynamic Programming • Brute Force • Approximation Algorithm • Randomized Algorithm
  • 17. Divide-and-Conquer Algorithm The divide and conquer algorithm has the following approach: 1) The problem is split (divided) into two distinct independent sub problems 2) The sub problems are solved (conquered) separately 3) The solutions to the sub problems are merged together to obtain solution to main problem.
  • 18. Divide-and-Conquer Algorithm Problem: Sort the set of numbers {25,10, 8, 45, 67, 33, 20, 59} in ascending order.
  • 19. Divide-and-Conquer Algorithm • Quick Sort • Merge Sort • Binary Search • Multiplication of Large Integers • Matrix Multiplication • Fast Fourier Transform
  • 20. Divide-and-Conquer Algorithm Divide and conquer algorithm provides efficient sorting and searching methods. It, however, has following limitations: • The divide-and-conquer algorithm is implemented using recursive function calls, which is not supported by some of the programming languages. • Recursive calls need large stacks to store intermediate results, utilize computer’s special memory called heap which may not be available on some systems and decrease data access speed • The divide-and-conquer algorithm is in-efficient when sub problems are not of nearly equal size.
  • 21. Greedy Algorithm Greedy Algorithm is designed to solve optimization problems. The greedy algorithm has the follows approach: 1) The problem is solved in steps. At each step, several choices are available for partial solutions. A greedy choice is made by selecting the option with maximum ( or minimum) cost. This is referred to as locally optimum solution, as opposed to globally optimum solution, which is expected to be the overall optimum solution. 2) It is checked if the selected option satisfies problems constraint ( for example, the cost does not exceed the prescribed limit ).This is referred to as feasible solution. 3) If current solution is not feasible, the next best option is selected. 4) Once a choice is made, it is not changed in subsequent steps. This condition is referred to as irrevocability
  • 22. Greedy Algorithm Problem: ATM is to deliver a change for Rs. 98, with minimum number of currency notes/coins.
  • 23. Greedy Algorithm Minimum Cabling in network • Prim’s Algorithm • Kruskal’s Algorithm Shortest route in a network • Dijkstara Algorithm Huffman coding for text compression Optimum Job Scheduling
  • 24. Greedy Algorithm The greedy algorithm provides is a simple and elegant solution to optimization problems. It has, however, the following limitations: • The greedy algorithm does not always produce a globally optimum solution , (for example, in case of traveling salesperson problem). • In order to check whether or not the resulting solution is optimal, further analysis is required. • Often the analysis for globally optimum solution is quite complex. • Analysis may requires additional resources.