Note: Because of the exam on 4/8, no late assignments will be accepted after Monday, 4/7, so that I can post solutions for you to study.
Home | | Syllabus | | Assignments | | Lecture Notes
one_third = (bottom + (top - bottom)/3).
Compute the index of the item 2/3 of the way along the list as follows:
two_thirds = (bottom + 2*(top-bottom)/3).
B. Include your function as an option in the testing program, (as we did with BS1 and BS2 in lab8), and examine its performance. You will need to provide a helper function, run_ternary( ) to initialize the parameters, as we did for BS1 and BS2 in lab8. You will find the search_compare.cc program along with associated list functions in:
You should copy these files into your own assignments directory.
Please run the comparisons in the
following order:
Modify the main() function of the search_compare program to accept a list length provided by the user for testing.
Test the average number of comparisons made for successful and unsuccessful searches of lists of length 5, 10, 20, 100, and 1000.
Write out the results for the ternary search (both successful and unsuccessful) in a table on a separate sheet and hand it in with this assignment.
C. Draw the comparison tree for a list of length 10. Use the convention used for the binary_search_2 tree developed in class.
Show your work and explain your answers. For example, for problem E2, indicate the appropriate rule or show the limit that lets you place one function above or below another in your list of functions. Also indicate which function grows fastest and which grows slowest.
Home | | Syllabus | | Assignments | | Lecture Notes
Constance Royden--croyden@mathcs.holycross.edu
Computer Science 132--Data Structures
Last Modified: March 27, 2014
Page Expires: January 14, 2015