SlideShare a Scribd company logo
What is the tight big-Oh running time of the following code segment?
a = 1
i = 1
while i < n
a = a * i
i = i + 1
endwhile
j = i
while j > 1
k = 1
while k < m
a = a + k -j
k = k + 1
endwhile
j = j / 2
endwhile
Solution
algorithm total steps:
a = 1 1
i = 1 1
while i < n   n+1
a = a * i n
i = i + 1 n
endwhile
j = i 1
while j > 1 n+1
k = 1 n
while k < m m+1
a = a + k -j mn
k = k + 1 mn
endwhile
j = j / 2 n
endwhile
therefore big oh running time is mn by eliminating all the lower values. we get the runing time
by adding all the above terms and neglecting the small values.

More Related Content

More from rtodd100

What is the significance of renaming the role of Programming Secretary.docx
What is the significance of renaming the role of Programming Secretary.docxWhat is the significance of renaming the role of Programming Secretary.docx
What is the significance of renaming the role of Programming Secretary.docxrtodd100
 
What is the primary role of internal controls in managing a busines- a.docx
What is the primary role of internal controls in managing a busines- a.docxWhat is the primary role of internal controls in managing a busines- a.docx
What is the primary role of internal controls in managing a busines- a.docxrtodd100
 
What is the pH of a saturated solution of Zn(OH)2 Ksp - 1-1-10-21- Sol.docx
What is the pH of a saturated solution of Zn(OH)2 Ksp - 1-1-10-21- Sol.docxWhat is the pH of a saturated solution of Zn(OH)2 Ksp - 1-1-10-21- Sol.docx
What is the pH of a saturated solution of Zn(OH)2 Ksp - 1-1-10-21- Sol.docxrtodd100
 
What is the pH of the buffer that results when 12-5 g sodium acetate (.docx
What is the pH of the buffer that results when 12-5 g sodium acetate (.docxWhat is the pH of the buffer that results when 12-5 g sodium acetate (.docx
What is the pH of the buffer that results when 12-5 g sodium acetate (.docxrtodd100
 
What is the magnetic field at point Q (20cm to the left of I1- 10cm to.docx
What is the magnetic field at point Q (20cm to the left of I1- 10cm to.docxWhat is the magnetic field at point Q (20cm to the left of I1- 10cm to.docx
What is the magnetic field at point Q (20cm to the left of I1- 10cm to.docxrtodd100
 
What is the final value of x after performing the following operations (1).docx
What is the final value of x after performing the following operations (1).docxWhat is the final value of x after performing the following operations (1).docx
What is the final value of x after performing the following operations (1).docxrtodd100
 
What is the difference between disk partitioning and formatting-Soluti.docx
What is the difference between disk partitioning and formatting-Soluti.docxWhat is the difference between disk partitioning and formatting-Soluti.docx
What is the difference between disk partitioning and formatting-Soluti.docxrtodd100
 
What is the difference in the TLS implementation that allows some expl.docx
What is the difference in the TLS implementation that allows some expl.docxWhat is the difference in the TLS implementation that allows some expl.docx
What is the difference in the TLS implementation that allows some expl.docxrtodd100
 
What is the difference between IS &IT- What is the difference betwee.docx
What is the difference between IS &IT-   What is the difference betwee.docxWhat is the difference between IS &IT-   What is the difference betwee.docx
What is the difference between IS &IT- What is the difference betwee.docxrtodd100
 
What is the difference between interfaced system and integrated system.docx
What is the difference between interfaced system and integrated system.docxWhat is the difference between interfaced system and integrated system.docx
What is the difference between interfaced system and integrated system.docxrtodd100
 
what is the difference between a single beam spectrophotometer and a d.docx
what is the difference between a single beam spectrophotometer and a d.docxwhat is the difference between a single beam spectrophotometer and a d.docx
what is the difference between a single beam spectrophotometer and a d.docxrtodd100
 
What is the difference between the formation of an ionic bond and form.docx
What is the difference between the formation of an ionic bond and form.docxWhat is the difference between the formation of an ionic bond and form.docx
What is the difference between the formation of an ionic bond and form.docxrtodd100
 
What is the difference between a direct and indirect interaction devic.docx
What is the difference between a direct and indirect interaction devic.docxWhat is the difference between a direct and indirect interaction devic.docx
What is the difference between a direct and indirect interaction devic.docxrtodd100
 
what is the difference an organic and inorganic moleculeSolutionCompou.docx
what is the difference an organic and inorganic moleculeSolutionCompou.docxwhat is the difference an organic and inorganic moleculeSolutionCompou.docx
what is the difference an organic and inorganic moleculeSolutionCompou.docxrtodd100
 
What is the conjugate base of H2SO4- What is the conjugate base of H.docx
What is the conjugate base of H2SO4-   What is the conjugate base of H.docxWhat is the conjugate base of H2SO4-   What is the conjugate base of H.docx
What is the conjugate base of H2SO4- What is the conjugate base of H.docxrtodd100
 

More from rtodd100 (15)

What is the significance of renaming the role of Programming Secretary.docx
What is the significance of renaming the role of Programming Secretary.docxWhat is the significance of renaming the role of Programming Secretary.docx
What is the significance of renaming the role of Programming Secretary.docx
 
What is the primary role of internal controls in managing a busines- a.docx
What is the primary role of internal controls in managing a busines- a.docxWhat is the primary role of internal controls in managing a busines- a.docx
What is the primary role of internal controls in managing a busines- a.docx
 
What is the pH of a saturated solution of Zn(OH)2 Ksp - 1-1-10-21- Sol.docx
What is the pH of a saturated solution of Zn(OH)2 Ksp - 1-1-10-21- Sol.docxWhat is the pH of a saturated solution of Zn(OH)2 Ksp - 1-1-10-21- Sol.docx
What is the pH of a saturated solution of Zn(OH)2 Ksp - 1-1-10-21- Sol.docx
 
What is the pH of the buffer that results when 12-5 g sodium acetate (.docx
What is the pH of the buffer that results when 12-5 g sodium acetate (.docxWhat is the pH of the buffer that results when 12-5 g sodium acetate (.docx
What is the pH of the buffer that results when 12-5 g sodium acetate (.docx
 
What is the magnetic field at point Q (20cm to the left of I1- 10cm to.docx
What is the magnetic field at point Q (20cm to the left of I1- 10cm to.docxWhat is the magnetic field at point Q (20cm to the left of I1- 10cm to.docx
What is the magnetic field at point Q (20cm to the left of I1- 10cm to.docx
 
What is the final value of x after performing the following operations (1).docx
What is the final value of x after performing the following operations (1).docxWhat is the final value of x after performing the following operations (1).docx
What is the final value of x after performing the following operations (1).docx
 
What is the difference between disk partitioning and formatting-Soluti.docx
What is the difference between disk partitioning and formatting-Soluti.docxWhat is the difference between disk partitioning and formatting-Soluti.docx
What is the difference between disk partitioning and formatting-Soluti.docx
 
What is the difference in the TLS implementation that allows some expl.docx
What is the difference in the TLS implementation that allows some expl.docxWhat is the difference in the TLS implementation that allows some expl.docx
What is the difference in the TLS implementation that allows some expl.docx
 
What is the difference between IS &IT- What is the difference betwee.docx
What is the difference between IS &IT-   What is the difference betwee.docxWhat is the difference between IS &IT-   What is the difference betwee.docx
What is the difference between IS &IT- What is the difference betwee.docx
 
What is the difference between interfaced system and integrated system.docx
What is the difference between interfaced system and integrated system.docxWhat is the difference between interfaced system and integrated system.docx
What is the difference between interfaced system and integrated system.docx
 
what is the difference between a single beam spectrophotometer and a d.docx
what is the difference between a single beam spectrophotometer and a d.docxwhat is the difference between a single beam spectrophotometer and a d.docx
what is the difference between a single beam spectrophotometer and a d.docx
 
What is the difference between the formation of an ionic bond and form.docx
What is the difference between the formation of an ionic bond and form.docxWhat is the difference between the formation of an ionic bond and form.docx
What is the difference between the formation of an ionic bond and form.docx
 
What is the difference between a direct and indirect interaction devic.docx
What is the difference between a direct and indirect interaction devic.docxWhat is the difference between a direct and indirect interaction devic.docx
What is the difference between a direct and indirect interaction devic.docx
 
what is the difference an organic and inorganic moleculeSolutionCompou.docx
what is the difference an organic and inorganic moleculeSolutionCompou.docxwhat is the difference an organic and inorganic moleculeSolutionCompou.docx
what is the difference an organic and inorganic moleculeSolutionCompou.docx
 
What is the conjugate base of H2SO4- What is the conjugate base of H.docx
What is the conjugate base of H2SO4-   What is the conjugate base of H.docxWhat is the conjugate base of H2SO4-   What is the conjugate base of H.docx
What is the conjugate base of H2SO4- What is the conjugate base of H.docx
 

Recently uploaded

Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Celine George
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersPedroFerreira53928
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdfVikramadityaRaj
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Celine George
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxakshayaramakrishnan21
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptSourabh Kumar
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticspragatimahajan3
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya - UEM Kolkata Quiz Club
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryEugene Lysak
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesashishpaul799
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Celine George
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/siemaillard
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeSaadHumayun7
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 

Recently uploaded (20)

Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 

What is the tight big-Oh running time of the following code segment- a.docx

  • 1. What is the tight big-Oh running time of the following code segment? a = 1 i = 1 while i < n a = a * i i = i + 1 endwhile j = i while j > 1 k = 1 while k < m a = a + k -j k = k + 1 endwhile j = j / 2 endwhile Solution algorithm total steps:
  • 2. a = 1 1 i = 1 1 while i < n   n+1 a = a * i n i = i + 1 n endwhile j = i 1 while j > 1 n+1 k = 1 n while k < m m+1 a = a + k -j mn k = k + 1 mn endwhile j = j / 2 n endwhile therefore big oh running time is mn by eliminating all the lower values. we get the runing time by adding all the above terms and neglecting the small values.