introduction to recursive formulations for …palash/courses/2021algorithms1... · 2021. 2. 4. ·...

13
INTRODUCTION TO RECURSIVE FORMULATIONS FOR ALGORITHM DESIGN: III Partha P Chakrabarti Indian Institute of Technology Kharagpur

Upload: others

Post on 05-Mar-2021

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

INTRODUCTION TO RECURSIVEFORMULATIONS FOR ALGORITHM DESIGN: III

Partha P ChakrabartiIndian Institute of Technology Kharagpur

Page 2: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

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
Page 3: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Piṅgala’s Numbers (3rd Century BC) The Chandaḥśāstra presents the first known description of a binary numeral system in

connection with the systematic enumeration of meters with fixed patterns of short and longsyllables. The discussion of the combinatorics of meter corresponds to the binomialtheorem. Halāyudha's commentary includes a presentation of the Pascal's triangle (calledmeruprastāra). Piṅgala's work also contains the Fibonacci numbers, called mātrāmeru.(later Bharata Muni (100 BC), Virahanka (700 AD), Hemachandra (1150 AD) – all beforeFibonacci 1200 AD)

Use of zero is sometimes ascribed to Piṅgala due to his discussion of binary numbers,usually represented using 0 and 1 in modern discussion, but Piṅgala used light (laghu) andheavy (guru) rather than 0 and 1 to describe syllables. As Piṅgala's system ranks binarypatterns starting at one (four short syllables—binary "0000"—is the first pattern), the nthpattern corresponds to the binary representation of n-1 (with increasing positional values).Piṅgala is thus credited with using binary numbers in the form of short and long syllables(the latter equal in length to two short syllables), a notation similar to Morse code.

Piṅgala used the Saṁskṛta word śūnya explicitly to refer to zero.

Partha P
Partha P
Partha P
Page 4: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Mātrāmeru or Fibonacci Numbers

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 …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Analyzing the Recursion Structure

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 6: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Memoization

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 …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Finalizing the Algorithm

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 …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Variations

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 9: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Evaluation of Fibonacci-like Recurrences

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 10: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Evaluation Algorithm

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 11: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Memoization Data Structure

Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Partha P
Page 12: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

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

Page 13: INTRODUCTION TO RECURSIVE FORMULATIONS FOR …palash/Courses/2021Algorithms1... · 2021. 2. 4. · Algorithm Design by Recursion Transformation 1. Initial Solution a. Recursive Definition

Thank you

Any Questions?