introduction to recursive formulations for algorithm …

1

Upload: others

Post on 09-Jan-2022

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

INTRODUCTION TO RECURSIVEFORMULATIONS FOR ALGORITHM DESIGN: II

Partha P ChakrabartiIndian Institute of Technology Kharagpur

Page 2: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Overview Algorithms and Programs Pseudo-Code Algorithms + Data Structures = Programs Initial Solutions + Analysis + Solution

Refinement + Data Structures = Final Algorithm

Use of Recursive Definitions as Initial Solutions

Recurrence Equations for Proofs and Analysis

Solution Refinement through Recursion Transformation and Traversal

Data Structures for saving past computation for future use

Sample Problems:1. Finding the Largest2. Largest and Smallest3. Largest and Second Largest4. Fibonacci Numbers5. Searching for an element in an ordered

/ unordered List6. Sorting7. Pattern Matching 8. Permutations and Combinations9. Layout and Routing10. Shortest Paths

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 3: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

3rd Problem: Largest and Second LargestSequential Comparison

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 4: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Largest and 2nd Largest: Recursive Formulation

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 5: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Largest and Next: Tournament

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 6: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Tournaments & Sorting

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 7: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Final Algorithms & Data Structuring

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 8: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Algorithms + Data Structures = Progams

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 9: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Algorithm Design by Recursion Transformation1. Initial Solution

a. Recursive Definition – A set of Solutionsb. Inductive Proof of Correctnessc. Analysis Using Recurrence Relations

2. Exploration of Possibilitiesa. Decomposition or Unfolding of the Recursion Treeb. Examination of Structures formedc. Re-composition Properties

3. Choice of Solution & Complexity Analysisa. Balancing the Split, Choosing Pathsb. Identical Sub-problems

4. Data Structures & Complexity Analysisa. Remembering Past Computation for Futureb. Space Complexity

5. Final Algorithm & Complexity Analysisa. Traversal of the Recursion Treeb. Pruning

6. Implementationa. Available Memory, Time, Quality of Solution, etc

Algorithms and Programs Pseudo-Code Algorithms + Data Structures = Programs Initial Solutions + Analysis + Solution

Refinement + Data Structures = Final Algorithm

Use of Recursive Definitions as Initial Solutions

Recurrence Equations for Proofs and Analysis

Solution Refinement through Recursion Transformation and Traversal

Data Structures for saving past computation for future use

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 10: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Overview of Algorithm Design 1. Initial Solution

a. Recursive Definition – A set of Solutionsb. Inductive Proof of Correctnessc. Analysis Using Recurrence Relations

2. Exploration of Possibilitiesa. Decomposition or Unfolding of the Recursion Treeb. Examination of Structures formedc. Re-composition Properties

3. Choice of Solution & Complexity Analysisa. Balancing the Split, Choosing Pathsb. Identical Sub-problems

4. Data Structures & Complexity Analysisa. Remembering Past Computation for Futureb. Space Complexity

5. Final Algorithm & Complexity Analysisa. Traversal of the Recursion Treeb. Pruning

6. Implementationa. Available Memory, Time, Quality of Solution, etc

1. Core Methodsa. Divide and Conquerb. Greedy Algorithmsc. Dynamic Programmingd. Branch-and-Bounde. Analysis using Recurrencesf. Advanced Data Structuring

2. Important Problems to be addresseda. Sorting and Searchingb. Strings and Patternsc. Trees and Graphsd. Combinatorial Optimization

3. Complexity & Advanced Topicsa. Time and Space Complexityb. Lower Boundsc. Polynomial Time, NP-Hardd. Parallelizability, Randomization

Partha P
Partha P
Page 11: INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM …

Thank you

Any Questions?