Is this correct in computing the time complexity in executing the program by using the formula in computing the heading and statement inside the FOR loop?

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 2GZ
icon
Related questions
Question

Is this correct in computing the time complexity in executing the program by using the formula in computing the heading and statement inside the FOR loop?

int fact=1;
{outside}
{outside}
{heading}
{
(1)
(1)
(5-1+1)+1
= 1
int n=5;
= 1
for (int i-1;i<=n;i++)
{begin}
{inside}
{end}
= 0
fact=fact*i;
(5-1+1)
}
{outside}
= 0
System.out.print("factorial is: "+fact);
(1)
= 1
14 ms
Transcribed Image Text:int fact=1; {outside} {outside} {heading} { (1) (1) (5-1+1)+1 = 1 int n=5; = 1 for (int i-1;i<=n;i++) {begin} {inside} {end} = 0 fact=fact*i; (5-1+1) } {outside} = 0 System.out.print("factorial is: "+fact); (1) = 1 14 ms
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT