7. Quantifying
algorithms
# Brian Cooper
#03/05/2021--8:00 pm
# this is meant to determine how long a program takes to run
# first import time libraray
import time
#Start time by setting the timer and setting vaule to start_time
start_time = time.time()
# next run code
for i in range(1000):
print("Hello everyone!")
# Set end time to end_time varia ble
end_time = time.time()
#determine totla time by subtracting end time from start time
# print time
# The {:.6F} is the way to format in this case to 6 floating point places after the ""
add .format(var to format)
print("nSeconds run 1000 times:{:.6F}".format(Total_time))
input("Press any key")
10. Big O Notation
First let's stop and talk about how
we can decide which is the fastest of
the algorithms we are learning
about.
11. Lists
Linked List Doubly linked list
This Photo by Unknown Author is licensed under CC BY
This Photo by Unknown Author is licensed under CC BY-SA
15. Sorting arrays
For many of the algorithms to work we must have the array
in order
Example…
Selection sort
Insertion sort
Shell sort
This Photo by Unknown Author is licensed under CC BY-SA