MTH120: Rosen Chapter 2.1
Since the pseudo code used in Rosen’s Discrete Mathematics is too profound (or just weird) for me, I thought I’d do the algorithms (or at least some of them) in php, and let ’em rip. So the following are some inputs for a couple of the problems in Chapter 2.
One thing I did need to do is to convert the lists of integers to arrays.
3. Find the sum of an array (list) of integers.
37. Optimize a bubble sort.
Realizing the built-in sort functions probably crank through things faster, this is a bubble sort that stops as soon as it gets the correct sort.