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) ] `}
Subjects List
Database (48)
Accounting (39)
Economics (34)
Finance (54)
Programming (122)
Management (69)
Marketing (25)
Report Writing (52)
Engineering (79)
Statistics (39)
Business Studies(45)
Case Studies (15)
Networking (26)
UML (9)
Science (23)
Nursing (11)
MATLAB (17)
Psychology (6)
Math (20)
Data Structure (9)
Python (15)
HRM (25)
IT (21)
Computer Science (57)
Law (4)
Essay (3)
Data Analysis (2)
Big Data (3)
Philosophy (2)
History (1)