Data Structures - Lab 03

Tuesday, September 8th

Exploring Complexity Analysis


Do not begin this lab until you receive directions from the instructor!

Today's lab will be different from our normal labs in that I will ask you to work with a partner so that you can actually stop and think about some code and talk it through with another student.  I believe that one of the BEST ways to learn something is to explain it to someone else. 

Also, this lab will ask you to carefully consider and explain code before you ever load it into the computer to run it.  It is important that you have made an honest effort to consider code and answer all questions before you actually run the code.  Again, I believe there is a lot to be learned from considering the code before you do anything with it.


Activity Set A   [Partner A writes code, Partner B completes answer sheet]


 


Activity Set B   [Partner B writes code, Partner A completes answer sheet]





 


Activity Set C   [Partner A writes code, Partner B completes answer sheet]

 

 

 

Table One : computation speed for different methods under different size loads.

search method testSize=5000 testSize=10000
methodOne    
methodTwo    
methodThree    
methodFour    
methodFive    

 

 

 

 


Activity Set D   [Partner B writes code, Partner A completes answer sheet]

 

Add methodThree() to lab3.py and then run it.  To test this code, try the following commands in the interactions pane and observe the results

  >>> data1 = range(0,10)
    >>> data1
    >>> methodThree(data1,5)
    >>> data2 = range(10,0,-1)
    >>> data2
    >>> methodThree(data2,5)

Notice that while 5 is contained in both lists methodThree() fails to locate it in data2

 

 

 

 

 


Activity Set E   [Partner A writes code, Partner B completes answer sheet]

 

 

Loop #firstlastmidpoint
1   
2   
3   
4   
5   
6   
7   
8   
9   

 

 

 


Activity Set F   [Partner B writes code, Partner A completes answer sheet]

 

 

 

 


Wrap Up [You pick who fills out the answer sheet]