SlideShare a Scribd company logo
1 of 9
Download to read offline
Data Structures and
Algorithms
By Prasanna Jatla
Sr Software Engineer
American Express
Basic Data Structures
• Overview of Arrays
• Overview of Linked Lists
• Overview of Stacks and Queues
What is
Recursion
• Recursionis a programming technique where a function calls itself directly or
indirectly.
• The function keeps calling itselfuntil a base case is reached, which stops the
recursion.
• Each recursive call typically creates a newactivation recordon the call stack.
• Recursionallows us to break down complex problems into smaller, self-similar
subproblems.
Advantages ofRecursion:
• Elegant solutions: Recursioncan provide elegantandconcise solutions to
problems that might be cumbersome with iterative approaches (using loops).
• Self-similar problems: Recursionshines when dealing with problems that
exhibitself-similarity, where the solution involves solving smaller versions ofthe
originalproblem.
• Improved readability: In some cases, recursive code canbe more readable
and easier tounderstandcompared to iterative solutions, especiallyfor
problems with inherentself-similarity.
Real-world
Applications
of Recursion
• Factorials: Calculating factorials of numbers is a
classic example of recursion.
• Tree traversals: Recursion is commonly used to
traverse tree data structures (like binary trees) in
a depth-firstmanner.
• File system navigation: Recursioncan be used
to navigate throughdirectory structureswithin a
file system.
• Maze solving algorithms: Several maze-solving
algorithms, like backtracking,utilize recursionto
explore differentpaths within the maze.
• Divide and conquer algorithms: Many divide-
and-conqueralgorithms, like merge sort and
quick sort, rely on recursionto break down
problems into smaller subproblems.
Analyzing time complexity
• Definition of AsymptoticNotation
• Importancein AnalyzingAlgorithm
Efficiency
• Definition of Big O Notation
• Analyzetime complexity of below code.
Dynamic Programming
• Core Idea: Breaks down a complex problem into smaller, overlapping
subproblems.
• Solves subproblems: Computes the optimal solutions for each
subproblem and stores them for reuse.
• Bottom-up approach: Builds solutions for larger subproblems using
previously solved smaller ones.
• Suitable for: Optimization problems with overlapping subproblems
(e.g., shortest path, edit distance).
Solving some Interview coding problems
• Generate all subsets , given an array of numbers
• K sum problem
• Check number of uni-value sub nodes in a tree.
Greedy Algorithms
• Core Idea: Makes the locally optimal choice at
each step with the hope of achieving a globally
optimal solution.
• Heuristic approach: Employs a set of rules to
make seemingly optimal choices at each step.
• Simpler implementation: Often easier to
understand and implement compared to
Dynamic Programming.
• No guarantee of global optimality: The locally
optimal choice at each step might not lead to the
overall best solution.
Q & A

More Related Content

Similar to Introduction to Algorithms And DataStructure

Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfLec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfMAJDABDALLAH3
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"GlobalLogic Ukraine
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structureSelf-Employed
 
Algorithms Design Patterns
Algorithms Design PatternsAlgorithms Design Patterns
Algorithms Design PatternsAshwin Shiv
 
Introduction to algorithn class 1
Introduction to algorithn class 1Introduction to algorithn class 1
Introduction to algorithn class 1Kumar
 
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dynamic programming, Branch and bound algorithm & Greedy algorithms Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dynamic programming, Branch and bound algorithm & Greedy algorithms SURBHI SAROHA
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxSyed Zaid Irshad
 
Dynamic programming 2
Dynamic programming 2Dynamic programming 2
Dynamic programming 2Roy Thomas
 
Module 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer methodModule 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer methodJyoReddy9
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of AlgorithmsBulbul Agrawal
 
Algorithm strategies in c++
Algorithm strategies in c++Algorithm strategies in c++
Algorithm strategies in c++Jawad Khan
 
9781285852744 ppt ch15
9781285852744 ppt ch159781285852744 ppt ch15
9781285852744 ppt ch15Terry Yoast
 
Convolutional Neural Networks : Popular Architectures
Convolutional Neural Networks : Popular ArchitecturesConvolutional Neural Networks : Popular Architectures
Convolutional Neural Networks : Popular Architecturesananth
 
Very largeoptimizationparallel
Very largeoptimizationparallelVery largeoptimizationparallel
Very largeoptimizationparallelAlkis Vazacopoulos
 
Chapter 13 - Recursion
Chapter 13 - RecursionChapter 13 - Recursion
Chapter 13 - RecursionAdan Hubahib
 

Similar to Introduction to Algorithms And DataStructure (20)

Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdfLec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
 
Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"Online TechTalk  "Patterns in Embedded SW Design"
Online TechTalk  "Patterns in Embedded SW Design"
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
 
Algorithms Design Patterns
Algorithms Design PatternsAlgorithms Design Patterns
Algorithms Design Patterns
 
Architecture presentation 4
Architecture presentation 4Architecture presentation 4
Architecture presentation 4
 
Introduction to algorithn class 1
Introduction to algorithn class 1Introduction to algorithn class 1
Introduction to algorithn class 1
 
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dynamic programming, Branch and bound algorithm & Greedy algorithms Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dynamic programming, Branch and bound algorithm & Greedy algorithms
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 
Dynamic programming 2
Dynamic programming 2Dynamic programming 2
Dynamic programming 2
 
CBD.pptx
CBD.pptxCBD.pptx
CBD.pptx
 
Module 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer methodModule 2ppt.pptx divid and conquer method
Module 2ppt.pptx divid and conquer method
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
Lec1.ppt
Lec1.pptLec1.ppt
Lec1.ppt
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Algorithm strategies in c++
Algorithm strategies in c++Algorithm strategies in c++
Algorithm strategies in c++
 
9781285852744 ppt ch15
9781285852744 ppt ch159781285852744 ppt ch15
9781285852744 ppt ch15
 
Convolutional Neural Networks : Popular Architectures
Convolutional Neural Networks : Popular ArchitecturesConvolutional Neural Networks : Popular Architectures
Convolutional Neural Networks : Popular Architectures
 
Very largeoptimizationparallel
Very largeoptimizationparallelVery largeoptimizationparallel
Very largeoptimizationparallel
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Chapter 13 - Recursion
Chapter 13 - RecursionChapter 13 - Recursion
Chapter 13 - Recursion
 

Recently uploaded

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Recently uploaded (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

Introduction to Algorithms And DataStructure

  • 1. Data Structures and Algorithms By Prasanna Jatla Sr Software Engineer American Express
  • 2. Basic Data Structures • Overview of Arrays • Overview of Linked Lists • Overview of Stacks and Queues
  • 3. What is Recursion • Recursionis a programming technique where a function calls itself directly or indirectly. • The function keeps calling itselfuntil a base case is reached, which stops the recursion. • Each recursive call typically creates a newactivation recordon the call stack. • Recursionallows us to break down complex problems into smaller, self-similar subproblems. Advantages ofRecursion: • Elegant solutions: Recursioncan provide elegantandconcise solutions to problems that might be cumbersome with iterative approaches (using loops). • Self-similar problems: Recursionshines when dealing with problems that exhibitself-similarity, where the solution involves solving smaller versions ofthe originalproblem. • Improved readability: In some cases, recursive code canbe more readable and easier tounderstandcompared to iterative solutions, especiallyfor problems with inherentself-similarity.
  • 4. Real-world Applications of Recursion • Factorials: Calculating factorials of numbers is a classic example of recursion. • Tree traversals: Recursion is commonly used to traverse tree data structures (like binary trees) in a depth-firstmanner. • File system navigation: Recursioncan be used to navigate throughdirectory structureswithin a file system. • Maze solving algorithms: Several maze-solving algorithms, like backtracking,utilize recursionto explore differentpaths within the maze. • Divide and conquer algorithms: Many divide- and-conqueralgorithms, like merge sort and quick sort, rely on recursionto break down problems into smaller subproblems.
  • 5. Analyzing time complexity • Definition of AsymptoticNotation • Importancein AnalyzingAlgorithm Efficiency • Definition of Big O Notation • Analyzetime complexity of below code.
  • 6. Dynamic Programming • Core Idea: Breaks down a complex problem into smaller, overlapping subproblems. • Solves subproblems: Computes the optimal solutions for each subproblem and stores them for reuse. • Bottom-up approach: Builds solutions for larger subproblems using previously solved smaller ones. • Suitable for: Optimization problems with overlapping subproblems (e.g., shortest path, edit distance).
  • 7. Solving some Interview coding problems • Generate all subsets , given an array of numbers • K sum problem • Check number of uni-value sub nodes in a tree.
  • 8. Greedy Algorithms • Core Idea: Makes the locally optimal choice at each step with the hope of achieving a globally optimal solution. • Heuristic approach: Employs a set of rules to make seemingly optimal choices at each step. • Simpler implementation: Often easier to understand and implement compared to Dynamic Programming. • No guarantee of global optimality: The locally optimal choice at each step might not lead to the overall best solution.