Q1. For each of the following 6 program fragments, give a Big-Oh analysis of the running time ( 1 ) sum = 0 ; f o r ( i

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Q1. For each of the following 6 program fragments, give a Big-Oh analysis of the running time ( 1 ) sum = 0 ; f o r ( i

Post by answerhappygod »

Q1. For each of the following 6 program fragments, give a Big-Ohanalysis of the running time( 1 )sum = 0 ;f o r ( i = 0 ; i < n ; i++ )++sum ;(2)
sum = 0 ;f o r ( i = 0 ; i < n ; i++ )f o r ( j = 0 ; j < n ; j++)++sum ;(3)
sum = 0 ;f o r ( i = 0 ; i < n ; i++ )f o r ( j = 0 ; j < n*m ; j++)++sum ;(4)
sum = 0 ;f o r ( i = 0 ; i < n ; i++ )f o r ( j = 0 ; j < i ; j++)++sum ;(5)
sum = 0 ;f o r ( i = 0 ; i < n ; i++ )f o r ( j = 0 ; j < i*i ; j++)for (k = 0; k < j; k++)++sum;(6)
sum = 0 ;f o r ( i = 0 ; i < n ; i++ )f o r ( j = 0 ; j < i*i ; j++)if (j % i == 0)for (k = 0; k < j; k++)
++sum;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply