e request you to not copy paste Those logic is wrong. I need correct one answer

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please request you to not copy paste

Those logic is wrong. I need correct one answer

 

Algorithm Timing
We will look at sorting algorithms more in-depth in the coming weeks. For now, it is sufficient to know that
these algorithms should take a (possibly) unsorted list as input, and modify that list until it is sorted. These
algorithms do not need to return anything in Python - when a collection is passed as an argument to a
function, any modificaitons to that collection are persistent outside of the function.
def bubble_sort (L):
n - len (L)
for i in range (n):
# no. of items in list
# for every item
for j in range (n): # compare to every other item
if L[i] < L[j]: # if out of order:
L[i], L[j] = L[j], L[i] # swap items
L = [1, 5, 4]
print (L) # eapect: [1, 5, 4]
bubble_sort (L)
print (L) # eæpect: [1, 4, 5]
TODO3 - TimingPlot.py
• Generate a series of x (number of items to sort) and y (time to sort) data using the above algorithm.
Use randomly sorted lists. For instance, to generate a list of 100 random integers, you might write:
import random
n - 100
L = [random.randint (0, n) for i in range (n)]
• Fit that data (n vs time) with the linear and quadratic functions. Choose n such that you can clearly
see the expected shape of the curve.
• Generate a figure with three curves:
a scatter plot of the raw data
- a line of best fit with lin
a line of best fit with quad
Follow best practices when presenting data:
Scale your data so the axes numbers are between 1 and 1000
Indlude axis labels with units
3
- Label each curve clearly, either with a textbox on the figure or a legend
Save your figure as "bestfit.png".
We are purposfully giving you flexibility here - how should you generate the lists as n grows? How should you
time the functions? You solved a very similar problem in lab; try to apply those techniques here.
Note that we will manually grade the final plot, and that you produced the data appropriately. Bad-faith
attempts (like arbitrarily generating numbers for your times) will not recieve any credit on this assignment.
Transcribed Image Text:Algorithm Timing We will look at sorting algorithms more in-depth in the coming weeks. For now, it is sufficient to know that these algorithms should take a (possibly) unsorted list as input, and modify that list until it is sorted. These algorithms do not need to return anything in Python - when a collection is passed as an argument to a function, any modificaitons to that collection are persistent outside of the function. def bubble_sort (L): n - len (L) for i in range (n): # no. of items in list # for every item for j in range (n): # compare to every other item if L[i] < L[j]: # if out of order: L[i], L[j] = L[j], L[i] # swap items L = [1, 5, 4] print (L) # eapect: [1, 5, 4] bubble_sort (L) print (L) # eæpect: [1, 4, 5] TODO3 - TimingPlot.py • Generate a series of x (number of items to sort) and y (time to sort) data using the above algorithm. Use randomly sorted lists. For instance, to generate a list of 100 random integers, you might write: import random n - 100 L = [random.randint (0, n) for i in range (n)] • Fit that data (n vs time) with the linear and quadratic functions. Choose n such that you can clearly see the expected shape of the curve. • Generate a figure with three curves: a scatter plot of the raw data - a line of best fit with lin a line of best fit with quad Follow best practices when presenting data: Scale your data so the axes numbers are between 1 and 1000 Indlude axis labels with units 3 - Label each curve clearly, either with a textbox on the figure or a legend Save your figure as "bestfit.png". We are purposfully giving you flexibility here - how should you generate the lists as n grows? How should you time the functions? You solved a very similar problem in lab; try to apply those techniques here. Note that we will manually grade the final plot, and that you produced the data appropriately. Bad-faith attempts (like arbitrarily generating numbers for your times) will not recieve any credit on this assignment.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY