Data Structures and Algorithms: S Aswin 17BCE1201
Data Structures and Algorithms: S Aswin 17BCE1201
Data Structures and Algorithms: S Aswin 17BCE1201
S ASWIN
17BCE1201
OVERVIEW OF THE PRESENTATION
• INTRODUCTION
• STACKS
• REAL LIFE APPLICATIONS
• RECURSION OR FUNCTION STACK
• OPTIMISATION
WHAT ARE DATA STRUCTURES
WHAT ARE DATA STRUCTURES
Data Structure is a way of HOW TO EFFECTIVELY SOLVE A
collecting and organizing data PROBLEM USING DATA
in such a way that we can
perform operations on these STRUCTURES AND ALGORITHMS
data in an effective way.
WHAT ARE ALGORITHMS
An algorithm in principle is
simply a series of instructions
that are followed step by step to
solve some problem or do
something useful. They have an
input which goes through a series
of computations, and finally
produces an output. TIME SPACE
COMPLEXITY COMPLEXITY
PUSH – INSERT AT THE TOP OF THE STACK
POP – POP THE TOP ELEMENT OF THE STACK
TOP – RETURN THE VALUE OF TOP ELEMENT OF THE STACK
EMPTY – CHECK IF STACK IS EMPTY
REAL LIFE PROBLEM
• Statement :
OUTPUT
O(N*N) O(N)
USING
STACK
OUTPUT AND COMPARISIONS
TIME TIME
COMPLEXITY COMPLEXITY
O(N*N) O(N)
SPACE SPACE
COMPLEXITY COMPLEXITY
O(N*N) O(N)
RECURSION
What is
Recursion?
The process in which a function
calls itself directly or indirectly
is called recursion and the
corresponding function is
called as recursive function.
USING RECURSION
DYNAMIC PROGRAMMING
• STORE THE VALUES INTO MEMORY AND USE THEM LATER
OUTPUT AND COMPARISIONS
TIME TIME
COMPLEXITY COMPLEXITY
O(2^N) O(N)
SPACE SPACE
COMPLEXITY COMPLEXITY
O(2^N) O(N)