C Course Homework


Homework 5 Sample Output

Your program should produce output similar to this. Note that I limited the values of my array elements to be in the range 0 to 99 by using the '%' (mod) operator when filling the array and when doing binary lookups. I ran the code for all 4 array sizes (10, 100, 1000, and 10000). For array size 10, I printed the array before sorting and after sorting, and I printed the results of 20 binary lookups. For array sizes 100, 1000, and 10000, I sorted the array and did 100 binary lookups but did not print the contents of the array or the results of the binary lookup.

 <----- output starts below here -----> 

RUNNING WITH 10 ELEMENTS 

  Before sorting array is:
	    4   82   81   46   35   65   33   17   56   19
  Sorting the array:
  After sorting array is:
	    4   17   19   33   35   46   56   65   81   82
  Doing 20 binary lookups:
    element =  0 not found; would be near index = 0
    element = 97 not found; would be near index = 9
    element = 18 not found; would be near index = 1
    element = 74 not found; would be near index = 7
    element = 40 not found; would be near index = 4
    element = 76 not found; would be near index = 7
    element = 82 found at index = 9
    element =  3 not found; would be near index = 0
    element = 81 found at index = 8
    element = 45 not found; would be near index = 4
    element = 86 not found; would be near index = 9
    element = 13 not found; would be near index = 0
    element = 50 not found; would be near index = 5
    element = 95 not found; would be near index = 9
    element = 64 not found; would be near index = 6
    element =  9 not found; would be near index = 0
    element = 24 not found; would be near index = 2
    element =  0 not found; would be near index = 0
    element = 20 not found; would be near index = 2
    element = 62 not found; would be near index = 6

RUNNING WITH 100 ELEMENTS 

  Sorting the array:
  Doing 100 binary lookups:

RUNNING WITH 1000 ELEMENTS 

  Sorting the array:
  Doing 100 binary lookups:

RUNNING WITH 10000 ELEMENTS 

  Sorting the array:
  Doing 100 binary lookups:
 <----- output ends above here ----->