------------------------------------------------------------------------------
MC logo
Ch. 10: Algorithms
[^] Chapter Outlines
------------------------------------------------------------------------------
<<Ch. 9: Executing Instructions Programming and Python>>
  1. Algorithm: A precise, systematic method for producing a specified result.
  2. Essential Properties.
    1. Inputs and outputs specified. Say what's needed, and what's produced.
    2. Definiteness.
      1. Each step is precisely defined.
      2. No “Sweeten sufficiently,” or “Be fair.”
    3. Effectiveness.
      1. The agent (computer or other) can perform each step.
      2. No “find tomorrows high temperature” or “enter the number I'm thinking of.”
    4. Finiteness.
      1. The algorithm must finish.
      2. No, “compute to the last digit the value of pi.”
  3. Languages.
    1. Programs are written in formal, precisely-defined languages.
    2. It's hard to write algorithms in human languages.
  4. Context.
    1. A set of assumptions made previous to running the algorithm.
    2. Algorithm usually fails when used out of context.
    3. For directions, what city you're in.
    4. For a program, type of platform.
  5. Alphabetize CDs example.
    1. Algorithm. Indents indicate the range of instructions repeated.
      Let Alpha denote the leftmost position.
      Let Beta denote the second position from the left.
      While Alpha has not yet reached the rightmost position, repeat:
            While Beta has not yet passed the right end of the rack, repeat:
                  if the CD in slot Alpha comes after the one in Beta, then
                        Swap the CD's in positions Alpha and Beta
                  Change Beta to denote the slot just right of its old position.
            Change Alpha to denote the slot just right of its old position.
            Change Beta to denote the slot just right Alpha.
      Stop 
      Example
    2. Loops.
      1. Loop properties.
        1. Progress.
        2. Termination.
      2. Two nested loops.
      3. Alpha sweep:
      4. Beta sweep:
<<Ch. 9: Executing Instructions Programming and Python>>