Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

7. ( 6 pts) State the running time of the following functions in Big O notation in terms of n, the size of the data

image text in transcribed
image text in transcribed
7. ( 6 pts) State the running time of the following functions in Big O notation in terms of n, the size of the data structure given to the function (a) Assume n is an int def populateList (n) : alist =[] for i in range (n) : alist. append (i) return alist (b) Assume myList is a list and i,j are integers def getLargervalue (mylist, i,j) : ans =0 if my 1 st [i]> mylist [j] : else: ans - mylist [1] return ans (c) Assume d is a dictionary that maps strings to numbers def getLargervalue (d,i,j) : ans =0 if d[1]>d[j]: else: ans=d[i]returnans=d[j] 6. ( 10 pts) What is the Big-O running time of the following code snippets in terms of n ? (a) x=0foriinrange(n):x=x+iforiinrange(n):x=x+i (b) x=0 for i in range (100n) : x=x+1 (c) x=0 for i in range (n) : for j in range (200) : (d) i=0 x=x+i+j while i1:i=i/2<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

Am I staying angry at someone, hoping to make him or her feel bad?

Answered: 1 week ago