logo
+1-617-874-1011 (US)
+61-7-5641-0117 (AU)
+44-117-230-1145 (UK)
Live Chat

Create an Analysis experiment program using simple Python code

Analysis program

Create an Analysis experiment program using simple Python code (Introductory Python).

Assignment list below:

-Devise an Analysis experiment to verify that get item and set item are O(1) for dictionaries.

-Measure the execution time for get and set for various size dictionaries of n entries. (Have the program create a table of executions times for each size output. Each line will have the size, set time, and get time with tabs (\t) between the numbers.)

-Run the program with different sizes to show that the times are constant with respect to the size.

The program below can be used as an example.

{`import time
def timeInsert(n):
l = list(range(n))
times = 750
lists = [ list(l) for i in range(times)]
t1 = time.time()
for i in range(times):
x = lists[i]
x.insert(n-1,"x")
x.insert(n//2,"x")
x.insert(0,"x")
t2 = time.time()
return (t2-t1)
zeros = 0
for n in range(1,50000,150):
t = timeInsert(n)
print( "%d\t%f" % (n,t))
if t == 0.0:
zeros = zeros + 1
print("zeros: ", zeros)
`}

The code below can be used as an example for creating a dictionary.

{`
d = dict()
for i in range(n):
d[i] = i
dicts = [ dict(d) for i in range(times) ]
`}
Improve Your Grades with Custom Writing Help
Homework Help
Writing Help
Editing Services
Plagiarism check
Proofreading services
Research Project help
Custom writing services
scanner
E learning blogs

Disclaimer : The study tools and academic assistance/guidance through online tutoring sessions provided by AssignmentHelp.Net is to help and enable students to compete academically. The website does not provide ghostwriting services and has ZERO TOLERANCE towards misuse of the services. In case any user is found misusing our services, the user's account will be immediately terminated.