Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

plz give me processthanks Please carefully read the following program: det sort (inputlist): for i in range(1, len(inputlist)): cur_value = inputList[i] j = i-1 while

plz give me processthanks image text in transcribed
Please carefully read the following program: det sort (inputlist): for i in range(1, len(inputlist)): cur_value = inputList[i] j = i-1 while j>=0 and inputList[i] > cur_value: inputlist[j+1] = inputList[j] j -= 1 inputList[j+1] = cur_value return inputList if name main_': inputList={10,4,2,4,5,6,7,1,2,3, 11, 14,1,2,3] print(sort (inputList)) Answer the following two questions: 1) Analyze the complexity of the function sort and write down the total cost of the function in the best and worst case. Briefly describe the rational behind your number. You must mention what is the cost for each line. For instance, line 2 cost c2 operation. You can ignore line 1. 2) What is the big-O of your two representations in answer to 1)

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

ISBN: 1285427106, 978-1285427102

Students also viewed these Databases questions