Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find () for code fragment 5 given in Figure 1. Your analysis should be patterned after the analysis in Figure 6 that used the example

Find () for code fragment 5 given in Figure 1. Your analysis should be patterned after the analysis in Figure 6 that used the example code fragment 0. Transform the code fragment into while-loops. Account for the cost of each line. Sum the total and express it in closed form.

A formal computation and verification demonstrating that () is (()).

image text in transcribed

image text in transcribed

example that proves t(n)=o(f(n))

image text in transcribed

int i 0 while(i1) Line Code Cost n-1o1-in n-1o1-in n-1o1-in 2 while(i1) 1-0 7 n-1o1-in 1 Total 2+4n+2n.log2m So, T(n) 24n2n.logm Find f(n). Let f(n) be the fastest growing term in T(n) with its coefficient removed. f(n) n 1. 2. Find C. 2.1. CCmin A, where A-1 (in many cases) Discrete Structures CMSC 2123 Code Fragment 5 Time Complexity Project po5 3n+3 2.3. In practice, Cmin is the coefficient of the fastest growing term in T( 4. Find no 4.1. Solve IT(no)l s CIf(no)l no 23 4.2. Choose an integer value for no. Let no3 We have shown that T(n) -3n+3 is O(n) because we have found witnesses C4 and no- 3<><>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions