Data Structures and Algorithms: S Aswin 17BCE1201

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

DATA STRUCTURES AND ALGORITHMS

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 :

• 73 -> wait for 1 day


• 74 -> wait for 1 day
• 75 -> wait for 4 days
BRUTE
FORCE
RESULTS

OUTPUT

TIME COMPLEXITY SPACE COMPLEXITY

O(N*N) O(N)
USING
STACK
OUTPUT AND COMPARISIONS

USING BRUTE FORCE USING STACK

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.

To store the temporary results


the function has it’s own
functional stack. Let’s take an
Example to understand.
FIBONACCI SERIES

USING RECURSION
DYNAMIC PROGRAMMING
• STORE THE VALUES INTO MEMORY AND USE THEM LATER
OUTPUT AND COMPARISIONS

USING RECURSION USING DYNAMIC PROGRAMMING

TIME TIME
COMPLEXITY COMPLEXITY

O(2^N) O(N)

SPACE SPACE
COMPLEXITY COMPLEXITY

O(2^N) O(N)

You might also like