SlideShare a Scribd company logo
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
Ad

Recommended

PPTX
CH-1.1 Introduction (1).pptx
satvikkushwaha1
 
PPT
Lecture01.ppt
InamUllahKhan961803
 
PPT
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Tekle12
 
PPT
Chapter1.1 Introduction.ppt
Tekle12
 
PPTX
Recursive Algorithm Detailed Explanation
Prapti Bhattacharjee
 
PPTX
Binary to hexadecimal algorithmic old.pptx
bulbul931579
 
PDF
Divide and Conquer Case Study
KushagraChadha1
 
PPTX
Introduction to dynamic programming
Amisha Narsingani
 
PDF
Introduction to analysis algorithm in computer Science
tissandavid
 
PDF
introduction to analysis of algorithm in computer science
tissandavid
 
PPTX
Algo_Lecture01.pptx
ShaistaRiaz4
 
PDF
Lecture 1 (bce-7)
farazahmad005
 
PDF
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
MAJDABDALLAH3
 
PPTX
Online TechTalk  "Patterns in Embedded SW Design"
GlobalLogic Ukraine
 
PPTX
Algorithm and C code related to data structure
Self-Employed
 
PPTX
Algorithms Design Patterns
Ashwin Shiv
 
PPT
Architecture presentation 4
Anoushiravan M. Ghamsari
 
PPTX
Introduction to algorithn class 1
Kumar
 
PPT
Mano PPT for introduction Computer Architecture .ppt
sudhansh5
 
PPTX
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dr. SURBHI SAROHA
 
PPTX
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
PPT
Dynamic programming 2
Roy Thomas
 
PPTX
CBD.pptx
RahulGautam663736
 
PPTX
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
PPTX
esign and Analysis of Algorithms Presentation.pptx
Niraj759370
 
PPTX
Analysis and Design of Algorithms
Bulbul Agrawal
 
PPT
Lec1.ppt
ssuser8bddb2
 
PPTX
Dynamic programming
Yıldırım Tam
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PPTX
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 

More Related Content

Similar to Introduction to Algorithms And DataStructure (20)

PDF
Introduction to analysis algorithm in computer Science
tissandavid
 
PDF
introduction to analysis of algorithm in computer science
tissandavid
 
PPTX
Algo_Lecture01.pptx
ShaistaRiaz4
 
PDF
Lecture 1 (bce-7)
farazahmad005
 
PDF
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
MAJDABDALLAH3
 
PPTX
Online TechTalk  "Patterns in Embedded SW Design"
GlobalLogic Ukraine
 
PPTX
Algorithm and C code related to data structure
Self-Employed
 
PPTX
Algorithms Design Patterns
Ashwin Shiv
 
PPT
Architecture presentation 4
Anoushiravan M. Ghamsari
 
PPTX
Introduction to algorithn class 1
Kumar
 
PPT
Mano PPT for introduction Computer Architecture .ppt
sudhansh5
 
PPTX
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dr. SURBHI SAROHA
 
PPTX
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
PPT
Dynamic programming 2
Roy Thomas
 
PPTX
CBD.pptx
RahulGautam663736
 
PPTX
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
PPTX
esign and Analysis of Algorithms Presentation.pptx
Niraj759370
 
PPTX
Analysis and Design of Algorithms
Bulbul Agrawal
 
PPT
Lec1.ppt
ssuser8bddb2
 
PPTX
Dynamic programming
Yıldırım Tam
 
Introduction to analysis algorithm in computer Science
tissandavid
 
introduction to analysis of algorithm in computer science
tissandavid
 
Algo_Lecture01.pptx
ShaistaRiaz4
 
Lecture 1 (bce-7)
farazahmad005
 
Lec07-Greedy Algorithms.pdf Lec07-Greedy Algorithms.pdf
MAJDABDALLAH3
 
Online TechTalk  "Patterns in Embedded SW Design"
GlobalLogic Ukraine
 
Algorithm and C code related to data structure
Self-Employed
 
Algorithms Design Patterns
Ashwin Shiv
 
Architecture presentation 4
Anoushiravan M. Ghamsari
 
Introduction to algorithn class 1
Kumar
 
Mano PPT for introduction Computer Architecture .ppt
sudhansh5
 
Dynamic programming, Branch and bound algorithm & Greedy algorithms
Dr. SURBHI SAROHA
 
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 
Dynamic programming 2
Roy Thomas
 
Module 2ppt.pptx divid and conquer method
JyoReddy9
 
esign and Analysis of Algorithms Presentation.pptx
Niraj759370
 
Analysis and Design of Algorithms
Bulbul Agrawal
 
Lec1.ppt
ssuser8bddb2
 
Dynamic programming
Yıldırım Tam
 

Recently uploaded (20)

PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PPTX
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
PPTX
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
PDF
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
PPTX
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
PDF
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
PDF
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
PDF
VCE Literature Section A Exam Response Guide
jpinnuck
 
PDF
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
PPTX
Q1_TLE 8_Week 1- Day 1 tools and equipment
clairenotado3
 
PPTX
Wage and Salary Computation.ppt.......,x
JosalitoPalacio
 
PDF
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
PPTX
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
PPTX
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
PPTX
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
PPTX
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
PPTX
How to Customize Quotation Layouts in Odoo 18
Celine George
 
PPTX
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
PDF
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
Public Health For The 21st Century 1st Edition Judy Orme Jane Powell
trjnesjnqg7801
 
June 2025 Progress Update With Board Call_In process.pptx
International Society of Service Innovation Professionals
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
LDMMIA Yoga S10 Free Workshop Grad Level
LDM & Mia eStudios
 
VCE Literature Section A Exam Response Guide
jpinnuck
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
Q1_TLE 8_Week 1- Day 1 tools and equipment
clairenotado3
 
Wage and Salary Computation.ppt.......,x
JosalitoPalacio
 
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
SCHIZOPHRENIA OTHER PSYCHOTIC DISORDER LIKE Persistent delusion/Capgras syndr...
parmarjuli1412
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
ENGLISH-5 Q1 Lesson 1.pptx - Story Elements
Mayvel Nadal
 
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
How to Customize Quotation Layouts in Odoo 18
Celine George
 
CRYPTO TRADING COURSE BY FINANCEWORLD.IO
AndrewBorisenko3
 
HistoPathology Ppt. Arshita Gupta for Diploma
arshitagupta674
 
Ad

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.