SlideShare a Scribd company logo
1 of 1
Download to read offline
In any given function in java, what do I need to look for in order to determine its space
complexity? thank you
Solution
You need to identify that is there any type of memory your creating locally in function to process
current execution of the function.
Type of memory generally can be created in function are:
1. local variables . ex int a, double y, String z etc : Space complexity : O(1) => constant
2. An Array, ArrayList, LinkedList, HashMap etc of size K => Space complexity : O(k)
For example:
void merge(int arr[], int l, int m, int r)
{
// Find sizes of two subarrays to be merged
int n1 = m - l + 1;
int n2 = r - m;
/* Create temp arrays */
int L[] = new int [n1]; // WE ARE CREATING EXTRA MEMORY
int R[] = new int [n2]; // WE ARE CREATING EXTRA MEMORY
/*Copy data to temp arrays*/
for (int i=0; i

More Related Content

Similar to In any given function in java, what do I need to look for in order t.pdf

Python 培训讲义
Python 培训讲义Python 培训讲义
Python 培训讲义leejd
 
Clojure made really really simple
Clojure made really really simpleClojure made really really simple
Clojure made really really simpleJohn Stevenson
 
Flying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightFlying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightWiem Zine Elabidine
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Codemotion
 
nlp dl 1.pdf
nlp dl 1.pdfnlp dl 1.pdf
nlp dl 1.pdfnyomans1
 
Class 32: Interpreters
Class 32: InterpretersClass 32: Interpreters
Class 32: InterpretersDavid Evans
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISPDevnology
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM CompilerErin Dees
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talkJohn Stevenson
 
Intro to threp
Intro to threpIntro to threp
Intro to threpHong Wu
 

Similar to In any given function in java, what do I need to look for in order t.pdf (17)

Python 培训讲义
Python 培训讲义Python 培训讲义
Python 培训讲义
 
Java
JavaJava
Java
 
Clojure made really really simple
Clojure made really really simpleClojure made really really simple
Clojure made really really simple
 
Flying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightFlying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnight
 
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
Functional Programming You Already Know - Kevlin Henney - Codemotion Rome 2015
 
TeraSort
TeraSortTeraSort
TeraSort
 
nlp dl 1.pdf
nlp dl 1.pdfnlp dl 1.pdf
nlp dl 1.pdf
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Class 32: Interpreters
Class 32: InterpretersClass 32: Interpreters
Class 32: Interpreters
 
C# programming
C# programming C# programming
C# programming
 
Space Complexity in Data Structure.docx
Space Complexity in Data Structure.docxSpace Complexity in Data Structure.docx
Space Complexity in Data Structure.docx
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Write Your Own JVM Compiler
Write Your Own JVM CompilerWrite Your Own JVM Compiler
Write Your Own JVM Compiler
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
 
Clojure made simple - Lightning talk
Clojure made simple - Lightning talkClojure made simple - Lightning talk
Clojure made simple - Lightning talk
 
Intro to threp
Intro to threpIntro to threp
Intro to threp
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
 

More from neetuarya13

Find the total cost of making a triangular sail that has a base dime.pdf
Find the total cost of making a triangular sail that has a base dime.pdfFind the total cost of making a triangular sail that has a base dime.pdf
Find the total cost of making a triangular sail that has a base dime.pdfneetuarya13
 
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdfExplain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdfneetuarya13
 
Define Managerial Accounting. Why do managers utilize managerial acc.pdf
Define Managerial Accounting. Why do managers utilize managerial acc.pdfDefine Managerial Accounting. Why do managers utilize managerial acc.pdf
Define Managerial Accounting. Why do managers utilize managerial acc.pdfneetuarya13
 
Describe how a third-generation language (3GL) programming language .pdf
Describe how a third-generation language (3GL) programming language .pdfDescribe how a third-generation language (3GL) programming language .pdf
Describe how a third-generation language (3GL) programming language .pdfneetuarya13
 
Biologists have very specific terminology (thats one of the things.pdf
Biologists have very specific terminology (thats one of the things.pdfBiologists have very specific terminology (thats one of the things.pdf
Biologists have very specific terminology (thats one of the things.pdfneetuarya13
 
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdfBacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdfneetuarya13
 
All of the following interactions can help hold the tertiary structur.pdf
All of the following interactions can help hold the tertiary structur.pdfAll of the following interactions can help hold the tertiary structur.pdf
All of the following interactions can help hold the tertiary structur.pdfneetuarya13
 
According to the figure below, which of the following statements reg.pdf
According to the figure below, which of the following statements reg.pdfAccording to the figure below, which of the following statements reg.pdf
According to the figure below, which of the following statements reg.pdfneetuarya13
 
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdfneetuarya13
 
A mirror faces a cliff located some distance away. Mounted on the cli.pdf
A mirror faces a cliff located some distance away. Mounted on the cli.pdfA mirror faces a cliff located some distance away. Mounted on the cli.pdf
A mirror faces a cliff located some distance away. Mounted on the cli.pdfneetuarya13
 
Why is it important to identify Classes early in the Unified Process.pdf
Why is it important to identify Classes early in the Unified Process.pdfWhy is it important to identify Classes early in the Unified Process.pdf
Why is it important to identify Classes early in the Unified Process.pdfneetuarya13
 
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdfA male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdfneetuarya13
 
Which of the following facilitated the endosymbiotic acquisition of .pdf
Which of the following facilitated the endosymbiotic acquisition of .pdfWhich of the following facilitated the endosymbiotic acquisition of .pdf
Which of the following facilitated the endosymbiotic acquisition of .pdfneetuarya13
 
Which of the following is true about replication    The lagging s.pdf
Which of the following is true about replication    The lagging s.pdfWhich of the following is true about replication    The lagging s.pdf
Which of the following is true about replication    The lagging s.pdfneetuarya13
 
Which is a common trait among all land plantsVascular tissues tra.pdf
Which is a common trait among all land plantsVascular tissues tra.pdfWhich is a common trait among all land plantsVascular tissues tra.pdf
Which is a common trait among all land plantsVascular tissues tra.pdfneetuarya13
 
Which of the following is an example of company whose business model .pdf
Which of the following is an example of company whose business model .pdfWhich of the following is an example of company whose business model .pdf
Which of the following is an example of company whose business model .pdfneetuarya13
 
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdfwhat role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdfneetuarya13
 
What are the similarities and differences between simple linear regr.pdf
What are the similarities and differences between simple linear regr.pdfWhat are the similarities and differences between simple linear regr.pdf
What are the similarities and differences between simple linear regr.pdfneetuarya13
 
What does it mean if a human female oocyte is no longer arrested in .pdf
What does it mean if a human female oocyte is no longer arrested in .pdfWhat does it mean if a human female oocyte is no longer arrested in .pdf
What does it mean if a human female oocyte is no longer arrested in .pdfneetuarya13
 
What is so important about the cells in the HeLo cell cultureWhat.pdf
What is so important about the cells in the HeLo cell cultureWhat.pdfWhat is so important about the cells in the HeLo cell cultureWhat.pdf
What is so important about the cells in the HeLo cell cultureWhat.pdfneetuarya13
 

More from neetuarya13 (20)

Find the total cost of making a triangular sail that has a base dime.pdf
Find the total cost of making a triangular sail that has a base dime.pdfFind the total cost of making a triangular sail that has a base dime.pdf
Find the total cost of making a triangular sail that has a base dime.pdf
 
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdfExplain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
Explain Charge, Current, Volta Power and Energy. Also explain relatio.pdf
 
Define Managerial Accounting. Why do managers utilize managerial acc.pdf
Define Managerial Accounting. Why do managers utilize managerial acc.pdfDefine Managerial Accounting. Why do managers utilize managerial acc.pdf
Define Managerial Accounting. Why do managers utilize managerial acc.pdf
 
Describe how a third-generation language (3GL) programming language .pdf
Describe how a third-generation language (3GL) programming language .pdfDescribe how a third-generation language (3GL) programming language .pdf
Describe how a third-generation language (3GL) programming language .pdf
 
Biologists have very specific terminology (thats one of the things.pdf
Biologists have very specific terminology (thats one of the things.pdfBiologists have very specific terminology (thats one of the things.pdf
Biologists have very specific terminology (thats one of the things.pdf
 
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdfBacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
Bacteria Characteristics Indole oxidase VP Cell Catalase reaction Sha.pdf
 
All of the following interactions can help hold the tertiary structur.pdf
All of the following interactions can help hold the tertiary structur.pdfAll of the following interactions can help hold the tertiary structur.pdf
All of the following interactions can help hold the tertiary structur.pdf
 
According to the figure below, which of the following statements reg.pdf
According to the figure below, which of the following statements reg.pdfAccording to the figure below, which of the following statements reg.pdf
According to the figure below, which of the following statements reg.pdf
 
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
3. A plant breeder crosses an inbred soybean cultivar with herbicide.pdf
 
A mirror faces a cliff located some distance away. Mounted on the cli.pdf
A mirror faces a cliff located some distance away. Mounted on the cli.pdfA mirror faces a cliff located some distance away. Mounted on the cli.pdf
A mirror faces a cliff located some distance away. Mounted on the cli.pdf
 
Why is it important to identify Classes early in the Unified Process.pdf
Why is it important to identify Classes early in the Unified Process.pdfWhy is it important to identify Classes early in the Unified Process.pdf
Why is it important to identify Classes early in the Unified Process.pdf
 
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdfA male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
A male Drosophila melanogaster has the genotype Aa; Bb; Cc; XDY..pdf
 
Which of the following facilitated the endosymbiotic acquisition of .pdf
Which of the following facilitated the endosymbiotic acquisition of .pdfWhich of the following facilitated the endosymbiotic acquisition of .pdf
Which of the following facilitated the endosymbiotic acquisition of .pdf
 
Which of the following is true about replication    The lagging s.pdf
Which of the following is true about replication    The lagging s.pdfWhich of the following is true about replication    The lagging s.pdf
Which of the following is true about replication    The lagging s.pdf
 
Which is a common trait among all land plantsVascular tissues tra.pdf
Which is a common trait among all land plantsVascular tissues tra.pdfWhich is a common trait among all land plantsVascular tissues tra.pdf
Which is a common trait among all land plantsVascular tissues tra.pdf
 
Which of the following is an example of company whose business model .pdf
Which of the following is an example of company whose business model .pdfWhich of the following is an example of company whose business model .pdf
Which of the following is an example of company whose business model .pdf
 
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdfwhat role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
what role(s) played by the Equatorial Segment Protein 1 (ESP1) durin.pdf
 
What are the similarities and differences between simple linear regr.pdf
What are the similarities and differences between simple linear regr.pdfWhat are the similarities and differences between simple linear regr.pdf
What are the similarities and differences between simple linear regr.pdf
 
What does it mean if a human female oocyte is no longer arrested in .pdf
What does it mean if a human female oocyte is no longer arrested in .pdfWhat does it mean if a human female oocyte is no longer arrested in .pdf
What does it mean if a human female oocyte is no longer arrested in .pdf
 
What is so important about the cells in the HeLo cell cultureWhat.pdf
What is so important about the cells in the HeLo cell cultureWhat.pdfWhat is so important about the cells in the HeLo cell cultureWhat.pdf
What is so important about the cells in the HeLo cell cultureWhat.pdf
 

Recently uploaded

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 

Recently uploaded (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

In any given function in java, what do I need to look for in order t.pdf

  • 1. In any given function in java, what do I need to look for in order to determine its space complexity? thank you Solution You need to identify that is there any type of memory your creating locally in function to process current execution of the function. Type of memory generally can be created in function are: 1. local variables . ex int a, double y, String z etc : Space complexity : O(1) => constant 2. An Array, ArrayList, LinkedList, HashMap etc of size K => Space complexity : O(k) For example: void merge(int arr[], int l, int m, int r) { // Find sizes of two subarrays to be merged int n1 = m - l + 1; int n2 = r - m; /* Create temp arrays */ int L[] = new int [n1]; // WE ARE CREATING EXTRA MEMORY int R[] = new int [n2]; // WE ARE CREATING EXTRA MEMORY /*Copy data to temp arrays*/ for (int i=0; i