You will be measuring the difference between linear and binary search for sorted arrays of various sizes.


You will receive an invitation for a git repository on All assignments in this class will be submitted by committing and pushing them to this git repository. Sign up for bitbucket (if you have not already) and follow the online directions to clone a copy of your repository. There is copious general help if you click the "?" at the top-right of the bitbucket window, and I have also created some local notes.

On GL, you will need to use the command-line git commands and the https version of the repository path from bitbucket. On other systems, you should be able to use either the ssh or https versions of the bitbucket repository path. Command line git tools should work on any platform. On Windows and Mac, I also like SourceTree as a git graphical interface.

Where ever you do your development, put everything for this assignment into the "assn1" directory in your repository.

For full credit, you must commit ("git commit") multiple times during development, and do at least one push ("git push") of your changes to the repository by the due date.

Search code

You may use any language that allows you to create contiguous arrays in memory. I recommend, but do not require, C or C++ since these languages put you in control of all memory allocation.

Write a program that allocates an array of given size and initializes it with sequential integers from 0 to the array size. Write two functions to find a random element in this array, one using linear search and one using binary search.


Add code to time N searches for random integers between 0 and the array size. Collect search time data for increasing array sizes for both linear and binary search.

Import these into a google spreadsheet and graph the average search time for each. This will be easiest if you create your program to output the timing results in CSV format.

691 students

Try also with a linked list and binary tree.


Edit "assn1/README.txt" to describe your test computer (at least OS and CPU), what language and compiler you used, and how to build and run your project. Also include an analysis of what conclusions you draw from your data.

Share your google spreadsheet with me and the grader. Include the google sharing link in your README.txt.