
| Line: 1 to 1 | ||||||||
|---|---|---|---|---|---|---|---|---|
| Added: | ||||||||
| > > |
Just search or sort then search?Learning Objective(s)
Overview of the programThe job is to do a number of searches on a set of data. When is it better to just search? When is it worth it to sort the data and then do you searches?Details
Sample dialogue (data results may not be accurate). Your dialogue may vary. It could be a lot shorted.How big of an array to you want to search? 1000What is the range of the data you want to search?1 9999 How many numbers o you want to search for? 20 It took 9878 comparisons to look up all 20 numbers (ranging from 1 to 9999) in a random array of 1000 numbers (in the same range). It took 15000 comparisons to sort the 1000 pieces of data. It took 200 comparisons to look up all 20 numbers (same range) in the sorted list (of 1000 numbers). Submission
Optional improvements
| |||||||