Question: 2 . You will write two different programs ( worth 1 0 points each ) , each one will demonstrate one algorithm. They will use

2. You will write two different programs (worth 10 points each), each one will demonstrate one algorithm. They will use the function below to fill the list of values:
import random
entries =100
def fill_list(n):
lst =[random.randint(0,n*10) for z in range (n)]
return lst
k = fill_list(entries)
print(k)
Part A -(1 point each) Estimate the Big Oh order for the following algorithms (write your answer below each:
# linear search when entries are out of orderAnswer:
# linear search when entries are in ascending order Answer:
# bubble sort when entries are out of order Answer:
# bubble sort when entries are in ascending order Answer:
# bubble sort when entries are in descending order Answer:
Part B - Write two programs, one for
Bubble sort and one for
Linear search
that will do the following:
1. fill a list using the fill_list random generation function (provided above)
2. determine the time it takes to run the algorithm with numbers in out of order
3. determine the time it takes to run the algorithm with numbers in ascending order
4. print results comparing the two runs with different orders

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!