Definitions

This section defines

  binaryFindIndex[ sortedList, number ]                           search a list for a number
  bubbleSort[ list ]                                                             sort a list with the bubble sort algorithm
  
as well as two utility functions for generating random lists
  
  randomList[ nItems, maxNumber ]
  randomSortedList[ nItems, maxNumber ]

and a few functions for testing things out.

Both binaryFindIndex and bubbleSort use two global variables for use in debugging and analysis, "verbose" and "loopCount".
To see how they're working, set "verbose=True", while to just have them shut up, set "verbose=False".
After either one runs, loopCount will be set to the number of times through the innermost loop.
  

RowBox[{(* a binary search algorithm *), , RowBox[{binaryFindIndex :: usage = "bi ... uot; number of comparisons in last sort was " <> ToString[loopCount]] ; ] ;}]}]


Created by Mathematica  (September 29, 2004)