Lesson 1: Introduction to Computation and Programming Flashcards
Algorithm
- An algorithm is a sequence of instructions for solving a particular type of problem.
…similar in meaning to: recipe, process, method, technique, procedure, routine.
Computation Problems
- Given a value (or set of values) called inputs
- Produce some value (or set of values) called outputs
Computation
- The transformation of data from inputs to outputs.
Statement of a Computational Problem
- Specifies the inputs and desired outputs (including their types and any restrictions).
Example: Given two coordinates (in lat-lon), compute the great circle distance (in nm) between them.
Instance of a Computational Problem
- Specifies the inputs and consists of all the inputs needed to compute a solution to the problem.
(satisfying whatever constraints might be imposed by the problem statement)
Example: What is the great circle distance (in nm) between (37° 37’ 8” N, 122° 22’ 29” W) and (41° 58’ 46” N, 87° 54’ 16” W)?
Important Properties of Algorithms
- Finiteness: An algorithm must always terminate after a finite number of steps.
- Definiteness: Each step of the algorithm must be precisely defined so that the actions can be carried out rigorously and unambiguously.
- Input: An algorithm has zero or more inputs—quantities that must be given before the algorithm begins.
- Output: An algorithm produces one or more outputs—quantities that have a specified relation to the inputs.
- Feasibility: All of the operations to be performed in the algorithm must be sufficiently basic that they can, in principle, be done exactly and in a finite length of time by hand (i.e., using pencil and paper).
Programming
- The act of implementing algorithms in a computer language to solve a problem.
In order to be successful in programming, you need:
- A specification of the computational problem to be solved:
- – the inputs (their types, meanings, restrictions)
- – the outputs (their types, meanings, restrictions)
- An algorithm to solve the problem.
- – Is it correct?
- – Is it efficient (how many resources does it require)?
- A means for storing and manipulating program data:
- – variables (types)
- – data structures (complex organizations of variables)
- A language for specifying the instructions: this controls the flow of program execution.
Computer
A machine that executes a set of instructions.
Instructions can be implemented in electronic hardware:
- Advantage: fast execution
- Disadvantages: single purpose, can’t be changed
Software
- Flexibility comes from the developement of software (logical instructions) that can be executed on standardized hardware (e.g., computer processing units or CPUs)
Machine Code
- Instructions that can be executed directly by the computing machines.
- – specific to hardware
- – expressed in binary
Computer Programming Language
- A higher level abstraction.
- – hardware independent
- – “human readable” instructions that make it more natural to implement an algorithm
Debugging
- The systematic process of removing bugs from code to obtain the intended program behavior
Domain Specific Programming Languages
- Languages dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique
Examples: Matlab, R, S-Plus, GAMS