Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 Worst-case Runtime Complexity Analysis (20 points) Determine the runtime complexity of the following functions. 3.1 Mystery function 'f' (5 points) 3.2 Mystery function 'g'

image text in transcribed

3 Worst-case Runtime Complexity Analysis (20 points) Determine the runtime complexity of the following functions. 3.1 Mystery function 'f' (5 points) 3.2 Mystery function 'g' (5 points) def f(head): # 1 is the head of a linked list of length n cur - head out = None while cur: lc = cur while lc: if not out: out - ListCell(cur.val, None) else: out - Listcell(cur.val, out.next) lc - lc.next cur - out.next out - None def g(1): # 1 is a python list of integers of length n s = len(1) while s > 1 : for i in range(e, len(1),s): 1[i] += 1 Ses // 2 -[] on) ] 0(n^2) i O(n^3) ] on log n) [] 0(n) [] on log n) [ ] 0(log n) - [] O(n^2) 1 3.3 Mystery function 'h' (5 points) 3.4 Mystery function 'i' (5 points) VNNN this function takes as input a number 'i'. For the runtime analysis we should consider the storage required to represent the number as the input size 'n'. Recall that a number i' requires o(log i)' bits to be represented. For instance, if '32' is passed as input then 'n - log 32 - 5 def h(i): # a number i t = i result - for j in range (2,t+1): if j>t: break while (t % j) == 0: t.tilj result.append() return result | def i(l): # a python list 1 low = 0 high - len(1) - 1 while low != high: if 1[low]

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_2

Step: 3

blur-text-image_3

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

Haptoware thenewe bys4bot

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago