SlideShare une entreprise Scribd logo
1  sur  1
Télécharger pour lire hors ligne
What is the T(n) and big O performance of the following function? This function gets a value as an
input and prints all prime numbers between 1 and the input number. Math.sgrt takes the square
root of a number import math def print alioprimes (n): for num in range (1,n+1): isprime = True for i
in range (2, int (1+ math.sqrt(num))): if num o =0 : isprime = False break if isprime: print (num)
Which one is faster? sorting a list of size n or to printing all prime numbers up to n ? Answer based
on both bubble sort and merge sort. Q5. Assume that that after analysizng a recursive function to
find it's T(n) you find that T(n)=1+2T(n/4) What is the big O performance of this function? Is it
faster or slower than binay search? Is it faster or slowe than merge sort? Hint: a(logx in base ak)=
x(1/k)

Contenu connexe

Similaire à What is the Tn and big O performance of the following func.pdf

how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
Sajid Marwat
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
chidabdu
 
Advanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfAdvanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdf
Sheba41
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
Abbas Ali
 
Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1
Vai Jayanthi
 

Similaire à What is the Tn and big O performance of the following func.pdf (20)

module1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdfmodule1_Introductiontoalgorithms_2022.pdf
module1_Introductiontoalgorithms_2022.pdf
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
chapter1.pdf ......................................
chapter1.pdf ......................................chapter1.pdf ......................................
chapter1.pdf ......................................
 
Slide2
Slide2Slide2
Slide2
 
Recurrence Relation
Recurrence RelationRecurrence Relation
Recurrence Relation
 
Basic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV SyllabusBasic Computer Engineering Unit II as per RGPV Syllabus
Basic Computer Engineering Unit II as per RGPV Syllabus
 
Algorithm chapter 2
Algorithm chapter 2Algorithm chapter 2
Algorithm chapter 2
 
Advanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdfAdvanced Datastructures and algorithms CP4151unit1b.pdf
Advanced Datastructures and algorithms CP4151unit1b.pdf
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
 
3 analysis.gtm
3 analysis.gtm3 analysis.gtm
3 analysis.gtm
 
Big Oh.ppt
Big Oh.pptBig Oh.ppt
Big Oh.ppt
 
Ada notes
Ada notesAda notes
Ada notes
 
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeksBeginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
Beginning direct3d gameprogrammingmath02_logarithm_20160324_jintaeks
 
Computational Complexity.pptx
Computational Complexity.pptxComputational Complexity.pptx
Computational Complexity.pptx
 
chapter1.ppt
chapter1.pptchapter1.ppt
chapter1.ppt
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
analysis.ppt
analysis.pptanalysis.ppt
analysis.ppt
 
pradeepbishtLecture13 div conq
pradeepbishtLecture13 div conqpradeepbishtLecture13 div conq
pradeepbishtLecture13 div conq
 
Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1Cs6402 daa-2 marks set 1
Cs6402 daa-2 marks set 1
 

Plus de adityaemporiyam

What part of aerobic respiration produces the most ATP Desc.pdf
What part of aerobic respiration produces the most ATP Desc.pdfWhat part of aerobic respiration produces the most ATP Desc.pdf
What part of aerobic respiration produces the most ATP Desc.pdf
adityaemporiyam
 
What is the Geologic Time Period Age of the formation expo.pdf
What is the Geologic Time Period Age of the formation expo.pdfWhat is the Geologic Time Period Age of the formation expo.pdf
What is the Geologic Time Period Age of the formation expo.pdf
adityaemporiyam
 

Plus de adityaemporiyam (20)

What mechanisms are used to move neurotransmitter back into .pdf
What mechanisms are used to move neurotransmitter back into .pdfWhat mechanisms are used to move neurotransmitter back into .pdf
What mechanisms are used to move neurotransmitter back into .pdf
 
What part of aerobic respiration produces the most ATP Desc.pdf
What part of aerobic respiration produces the most ATP Desc.pdfWhat part of aerobic respiration produces the most ATP Desc.pdf
What part of aerobic respiration produces the most ATP Desc.pdf
 
What is the structure circled in purple below Be very speci.pdf
What is the structure circled in purple below Be very speci.pdfWhat is the structure circled in purple below Be very speci.pdf
What is the structure circled in purple below Be very speci.pdf
 
What isare the parameters in the regression function belo.pdf
What isare the parameters in the regression function belo.pdfWhat isare the parameters in the regression function belo.pdf
What isare the parameters in the regression function belo.pdf
 
What kind of epithelium is found in the trachea bronchi na.pdf
What kind of epithelium is found in the trachea bronchi na.pdfWhat kind of epithelium is found in the trachea bronchi na.pdf
What kind of epithelium is found in the trachea bronchi na.pdf
 
What is the vesting requirement for employee benefits A It.pdf
What is the vesting requirement for employee benefits A It.pdfWhat is the vesting requirement for employee benefits A It.pdf
What is the vesting requirement for employee benefits A It.pdf
 
What is the weighted beta of the portfolio Round your answe.pdf
What is the weighted beta of the portfolio Round your answe.pdfWhat is the weighted beta of the portfolio Round your answe.pdf
What is the weighted beta of the portfolio Round your answe.pdf
 
What is the underlying factor that allowed George Soros suc.pdf
What is the underlying factor that allowed George Soros suc.pdfWhat is the underlying factor that allowed George Soros suc.pdf
What is the underlying factor that allowed George Soros suc.pdf
 
What is the output on console public static void mainString.pdf
What is the output on console public static void mainString.pdfWhat is the output on console public static void mainString.pdf
What is the output on console public static void mainString.pdf
 
What is the problem with Bluetooth and IEEE 80211b WLANs us.pdf
What is the problem with Bluetooth and IEEE 80211b WLANs us.pdfWhat is the problem with Bluetooth and IEEE 80211b WLANs us.pdf
What is the problem with Bluetooth and IEEE 80211b WLANs us.pdf
 
What is the output if n is 3 for int i 1 i lt n ++.pdf
What is the output if n is 3 for int i  1 i lt n ++.pdfWhat is the output if n is 3 for int i  1 i lt n ++.pdf
What is the output if n is 3 for int i 1 i lt n ++.pdf
 
What is the most accurate discription of the best winwin .pdf
What is the most accurate discription of the best winwin .pdfWhat is the most accurate discription of the best winwin .pdf
What is the most accurate discription of the best winwin .pdf
 
What is the function of the parental DNA in replication Wha.pdf
What is the function of the parental DNA in replication Wha.pdfWhat is the function of the parental DNA in replication Wha.pdf
What is the function of the parental DNA in replication Wha.pdf
 
What is the genotype of the first female in the second row .pdf
What is the genotype of the first female in the second row .pdfWhat is the genotype of the first female in the second row .pdf
What is the genotype of the first female in the second row .pdf
 
What is the primary composition of the Jovian planets Hydro.pdf
What is the primary composition of the Jovian planets Hydro.pdfWhat is the primary composition of the Jovian planets Hydro.pdf
What is the primary composition of the Jovian planets Hydro.pdf
 
What is the major physical symptom associated with Klinefelt.pdf
What is the major physical symptom associated with Klinefelt.pdfWhat is the major physical symptom associated with Klinefelt.pdf
What is the major physical symptom associated with Klinefelt.pdf
 
What is the Geologic Time Period Age of the formation expo.pdf
What is the Geologic Time Period Age of the formation expo.pdfWhat is the Geologic Time Period Age of the formation expo.pdf
What is the Geologic Time Period Age of the formation expo.pdf
 
What is the pvalue if in a twotail hypothesis test ZSTAT.pdf
What is the pvalue if in a twotail hypothesis test ZSTAT.pdfWhat is the pvalue if in a twotail hypothesis test ZSTAT.pdf
What is the pvalue if in a twotail hypothesis test ZSTAT.pdf
 
What is the meaning of the term cost bias in Hussain and .pdf
What is the meaning of the term cost bias in Hussain and .pdfWhat is the meaning of the term cost bias in Hussain and .pdf
What is the meaning of the term cost bias in Hussain and .pdf
 
What is the first step in energy flow through an ecosystem .pdf
What is the first step in energy flow through an ecosystem .pdfWhat is the first step in energy flow through an ecosystem .pdf
What is the first step in energy flow through an ecosystem .pdf
 

Dernier

Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
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
QucHHunhnh
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 

Dernier (20)

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
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
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
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.
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
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
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 

What is the Tn and big O performance of the following func.pdf

  • 1. What is the T(n) and big O performance of the following function? This function gets a value as an input and prints all prime numbers between 1 and the input number. Math.sgrt takes the square root of a number import math def print alioprimes (n): for num in range (1,n+1): isprime = True for i in range (2, int (1+ math.sqrt(num))): if num o =0 : isprime = False break if isprime: print (num) Which one is faster? sorting a list of size n or to printing all prime numbers up to n ? Answer based on both bubble sort and merge sort. Q5. Assume that that after analysizng a recursive function to find it's T(n) you find that T(n)=1+2T(n/4) What is the big O performance of this function? Is it faster or slower than binay search? Is it faster or slowe than merge sort? Hint: a(logx in base ak)= x(1/k)