SlideShare a Scribd company logo
2
Most read
3
Most read
8
Most read
Space complexity
Unit I Part 2
Creative Commons License
Space Complexity by Bhanusree Yalamanchili is licensed under a Creative Commons
Attribution-ShareAlike 4.0 International License.
Space Complexity
Amount of computer memory that is required during program execution as a function of input
size.
OR
Space complexity is the amount of memory it needs to run to completion
Space=Fixed part +Variable part
Fixed: varies from problem to problem. Includes space needed for storing instructions
variables , constants and structured variables.[arrays , struct]
Variable: varies from program to program. Includes space needed for stack and for
structured variables that are dynamically allocated during run time.
219-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor
 Fixed Space Requirements (C)
Independent of the characteristics of the inputs and outputs
 instruction space(space for code)
 space for simple variables, fixed-size structured variable, constants
 Variable Space Requirements (SP(I))
depend on the instance characteristic I
 number, size, values of inputs and outputs associated with I
 recursive stack space, formal parameters, local variables, return address
3
S(P)=C+SP(I)
19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor
Algorithm abc(a,b,c)
{
return a+b*c+(a-b-)/a+b+4.0
}
Algorithm Sum(a,n)
{
s:=0
for i:=1 to n do
s:=s+a[i];
return s;
}
19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor 4
Ex:1
float abc(float a, float b, float c)
{
return a + b + b * c + (a + b - c) / (a + b) + 4.00;
}
Sabc(I) = 0
519-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor
Ex:2
float sum(float list[ ], int n)
{
float tempsum = 0;
int i;
for (i = 0; i<n; i++)
tempsum += list [i];
return tempsum;
}
Ssum(I) = 0
19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor 6
Exercise
Find space complexity for the following algorithms:
• Swap
• Maximum
• Minimum
• Selection sort
• Matrix display
• Matrix multiplication
19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor 7
Ex:3 Recursive function for summing a list of numbers
float sum(float list[ ], int n)
{
if (n)
return sum(list, n-1) + list[n];
else
return 0;
}
8
Type Name Number of bytes
parameter: float
parameter: integer
return address:(used internally)
list [ ]
n
4
2
2(unless a far address)
TOTAL per recursive call 8
Ssum(I)=Ssum(n)=8n
19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor

More Related Content

What's hot (20)

PPTX
Computer graphics chapter 4
PrathimaBaliga
 
PPT
Instruction cycle
shweta-sharma99
 
PPT
Deadlock
Rajandeep Gill
 
PDF
Time and Space Complexity
Ashutosh Satapathy
 
PPTX
Performance analysis(Time & Space Complexity)
swapnac12
 
PDF
UNIT-V.pdf daa unit material 5 th unit ppt
JyoReddy9
 
PPTX
Three address code In Compiler Design
Shine Raj
 
PPTX
Three Address code
Pooja Dixit
 
PPT
Divide and Conquer
Dr Shashikant Athawale
 
PPTX
Critical section problem in operating system.
MOHIT DADU
 
PPT
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
PPTX
Computer arithmetic
Balakrishna Chowdary
 
PPTX
Operating system paging and segmentation
hamza haseeb
 
PPTX
Monitors & workstation,Donald ch-2
Iftikhar Ahmad
 
PPT
Intermediate code generation (Compiler Design)
Tasif Tanzim
 
PPT
Visible surface detection in computer graphic
anku2266
 
PDF
region-filling
Kumar
 
PPS
Computer instructions
Anuj Modi
 
PPTX
Parallel projection
Prince Shahu
 
PPTX
Video display devices
shalinikarunakaran1
 
Computer graphics chapter 4
PrathimaBaliga
 
Instruction cycle
shweta-sharma99
 
Deadlock
Rajandeep Gill
 
Time and Space Complexity
Ashutosh Satapathy
 
Performance analysis(Time & Space Complexity)
swapnac12
 
UNIT-V.pdf daa unit material 5 th unit ppt
JyoReddy9
 
Three address code In Compiler Design
Shine Raj
 
Three Address code
Pooja Dixit
 
Divide and Conquer
Dr Shashikant Athawale
 
Critical section problem in operating system.
MOHIT DADU
 
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
Computer arithmetic
Balakrishna Chowdary
 
Operating system paging and segmentation
hamza haseeb
 
Monitors & workstation,Donald ch-2
Iftikhar Ahmad
 
Intermediate code generation (Compiler Design)
Tasif Tanzim
 
Visible surface detection in computer graphic
anku2266
 
region-filling
Kumar
 
Computer instructions
Anuj Modi
 
Parallel projection
Prince Shahu
 
Video display devices
shalinikarunakaran1
 

Viewers also liked (13)

PPTX
CPU & RAM
Redoan Ur Rahman
 
PPT
Chapter7 Computer Networks
Muhammad Waqas
 
PPT
Time andspacecomplexity
LAKSHMITHARUN PONNAM
 
PDF
CIM/e-Marketing Award-Assignment # 3 and #4 (combined): A Full Fledge e-Marke...
Naja Faysal
 
PPT
Time complexity
Katang Isip
 
PPT
Complexity of Algorithm
Muhammad Muzammal
 
DOC
Time and space complexity
Ankit Katiyar
 
PDF
WDL - como criar nomes para empresas
We Do Logos
 
PPTX
Building Healthier Communities: TEDMED 2016
Luminary Labs
 
PPTX
Culture
Reed Hastings
 
PDF
TEDx Manchester: AI & The Future of Work
Volker Hirsch
 
PDF
Build Features, Not Apps
Natasha Murashev
 
PDF
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
SlideShare
 
CPU & RAM
Redoan Ur Rahman
 
Chapter7 Computer Networks
Muhammad Waqas
 
Time andspacecomplexity
LAKSHMITHARUN PONNAM
 
CIM/e-Marketing Award-Assignment # 3 and #4 (combined): A Full Fledge e-Marke...
Naja Faysal
 
Time complexity
Katang Isip
 
Complexity of Algorithm
Muhammad Muzammal
 
Time and space complexity
Ankit Katiyar
 
WDL - como criar nomes para empresas
We Do Logos
 
Building Healthier Communities: TEDMED 2016
Luminary Labs
 
Culture
Reed Hastings
 
TEDx Manchester: AI & The Future of Work
Volker Hirsch
 
Build Features, Not Apps
Natasha Murashev
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
SlideShare
 
Ad

Similar to Space complexity (20)

KEY
GoLightly: Building VM-Based Language Runtimes with Google Go
Eleanor McHugh
 
PPT
10.ppt
BNJYOTHI
 
PDF
Computer science ms
B Bhuvanesh
 
PPT
FDS- Basic Concepts.ppt
shanthishyam
 
PDF
The present and the future of functional programming in c++
Alexander Granin
 
PDF
C mcq practice test 4
Aman Kamboj
 
PDF
Advanced Web Technology ass.pdf
simenehanmut
 
PDF
The Present and The Future of Functional Programming in C++
Alexander Granin
 
PPTX
Functions in c++,
Padma Kannan
 
PDF
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
John De Goes
 
PDF
Preprocessor directives
Vikash Dhal
 
PPT
chapter1.ppt
chetanvchaudhari
 
PPT
chapter1.ppt
SankarTerli
 
PDF
Chapter 1 Basic Programming (Python Programming Lecture)
IoT Code Lab
 
PDF
C++ for Engineers and Scientists 4th Edition Bronson Test Bank
cjunotakni
 
PPT
DAA-Introduction-Divide and Conquer Technique
sailaja156145
 
PPTX
APSEC2020 Keynote
Abhik Roychoudhury
 
PPTX
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
PPT
Basic_analysis.ppt
SoumyaJ3
 
PDF
Code quailty metrics demystified
Jeroen Resoort
 
GoLightly: Building VM-Based Language Runtimes with Google Go
Eleanor McHugh
 
10.ppt
BNJYOTHI
 
Computer science ms
B Bhuvanesh
 
FDS- Basic Concepts.ppt
shanthishyam
 
The present and the future of functional programming in c++
Alexander Granin
 
C mcq practice test 4
Aman Kamboj
 
Advanced Web Technology ass.pdf
simenehanmut
 
The Present and The Future of Functional Programming in C++
Alexander Granin
 
Functions in c++,
Padma Kannan
 
Blazing Fast, Pure Effects without Monads — LambdaConf 2018
John De Goes
 
Preprocessor directives
Vikash Dhal
 
chapter1.ppt
chetanvchaudhari
 
chapter1.ppt
SankarTerli
 
Chapter 1 Basic Programming (Python Programming Lecture)
IoT Code Lab
 
C++ for Engineers and Scientists 4th Edition Bronson Test Bank
cjunotakni
 
DAA-Introduction-Divide and Conquer Technique
sailaja156145
 
APSEC2020 Keynote
Abhik Roychoudhury
 
2.2 stack applications Infix to Postfix & Evaluation of Post Fix
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Basic_analysis.ppt
SoumyaJ3
 
Code quailty metrics demystified
Jeroen Resoort
 
Ad

Recently uploaded (20)

PPTX
Precedence and Associativity in C prog. language
Mahendra Dheer
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
All chapters of Strength of materials.ppt
girmabiniyam1234
 
PDF
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
PPTX
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
PDF
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
PDF
STUDY OF NOVEL CHANNEL MATERIALS USING III-V COMPOUNDS WITH VARIOUS GATE DIEL...
ijoejnl
 
PPTX
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
PDF
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
PPTX
Online Cab Booking and Management System.pptx
diptipaneri80
 
PPTX
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 
Precedence and Associativity in C prog. language
Mahendra Dheer
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
All chapters of Strength of materials.ppt
girmabiniyam1234
 
Machine Learning All topics Covers In This Single Slides
AmritTiwari19
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Natural_Language_processing_Unit_I_notes.pdf
sanguleumeshit
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
Construction of a Thermal Vacuum Chamber for Environment Test of Triple CubeS...
2208441
 
STUDY OF NOVEL CHANNEL MATERIALS USING III-V COMPOUNDS WITH VARIOUS GATE DIEL...
ijoejnl
 
MULTI LEVEL DATA TRACKING USING COOJA.pptx
dollysharma12ab
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
SG1-ALM-MS-EL-30-0008 (00) MS - Isolators and disconnecting switches.pdf
djiceramil
 
Online Cab Booking and Management System.pptx
diptipaneri80
 
ENSA_Module_7.pptx_wide_area_network_concepts
RanaMukherjee24
 

Space complexity

  • 1. Space complexity Unit I Part 2 Creative Commons License Space Complexity by Bhanusree Yalamanchili is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
  • 2. Space Complexity Amount of computer memory that is required during program execution as a function of input size. OR Space complexity is the amount of memory it needs to run to completion Space=Fixed part +Variable part Fixed: varies from problem to problem. Includes space needed for storing instructions variables , constants and structured variables.[arrays , struct] Variable: varies from program to program. Includes space needed for stack and for structured variables that are dynamically allocated during run time. 219-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor
  • 3.  Fixed Space Requirements (C) Independent of the characteristics of the inputs and outputs  instruction space(space for code)  space for simple variables, fixed-size structured variable, constants  Variable Space Requirements (SP(I)) depend on the instance characteristic I  number, size, values of inputs and outputs associated with I  recursive stack space, formal parameters, local variables, return address 3 S(P)=C+SP(I) 19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor
  • 4. Algorithm abc(a,b,c) { return a+b*c+(a-b-)/a+b+4.0 } Algorithm Sum(a,n) { s:=0 for i:=1 to n do s:=s+a[i]; return s; } 19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor 4
  • 5. Ex:1 float abc(float a, float b, float c) { return a + b + b * c + (a + b - c) / (a + b) + 4.00; } Sabc(I) = 0 519-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor
  • 6. Ex:2 float sum(float list[ ], int n) { float tempsum = 0; int i; for (i = 0; i<n; i++) tempsum += list [i]; return tempsum; } Ssum(I) = 0 19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor 6
  • 7. Exercise Find space complexity for the following algorithms: • Swap • Maximum • Minimum • Selection sort • Matrix display • Matrix multiplication 19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor 7
  • 8. Ex:3 Recursive function for summing a list of numbers float sum(float list[ ], int n) { if (n) return sum(list, n-1) + list[n]; else return 0; } 8 Type Name Number of bytes parameter: float parameter: integer return address:(used internally) list [ ] n 4 2 2(unless a far address) TOTAL per recursive call 8 Ssum(I)=Ssum(n)=8n 19-01-2017 VNRVJIET::CSE Author: Y.Bhanusree, Assistant Professor