Monday, February 22, 2010

C++ Code for Minimum Value

Here is some code that I wrote while learning about vectors and templates.  The code takes a large sequence of numbers and finds the smallest value for a smaller segment of the larger sequence.  This is repeated for each small segment that fits into the larger segment.

Example:
   We have a large sequence (size 20) and want to find the minimum value for each small segment (size 5).

Large Sequence:
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

1st Small Sequence               Output
 1 2 3 4 5                                   1

2nd Small Sequence              Output
 6 7 8 9 10                                 6

3rd Small Sequence               Output
 11 12 13 14 15                         11

4th Small Sequence               Output
 16 17 18 19 20                         16
 Code:
    Here is the code

No comments:

Post a Comment