Question
Assume n is a positive integer Our goal is to find a power function g n n such that the algorithm below is O n
Assume n is a positive integer Our goal is to find a power function g n n such that the algorithm below is O n x 6 for i 1 to n for j 3 to 3i x x i j next j next i 1 Start by counting the number of operations performed in the inner loop This total will depend on i In each iteration of the inner loop The inner loop runs operations are performed times so the total number of operations performed in this loop is 2 With the information above we can count the number of operations the overall algorithm computes In ith iteration of the outer loop operations are performed This total depends on the value of i To get the total number of operations we need to add up the number of operations performed for each value of the total number of operations performed in this loop is That is
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started