2 What Computer Science Is Not Computer Science (CS) = Study of Computers? CS began earlier than computers (branch of math) Theoretical CS (pencil and paper) Computer is only the basic tool in CS (e.g. beaker for chemistry, microscope for biology etc.)
3 What Computer Science Is Not CS = Study of how to write programs? Use of programming languages e.g. Pascal, Lisp, C, etc. Very important but also only a tool in CS for verifying ideas and concepts after their analysis. Example: “ Searching in a list ” Analyze the problem Design a searching method Write a program Get quantitative and qualitative results.
4 What Computer Science Is Not CS = Study of computer applications and software? Application: e.g. spreadsheets, word processors, databases … Comparison: Mechanical Engineer Computer Scientist Conceives a car conceives computer/software Builds and tests it builds and tests it User Gets a driver license Gets some certificate Drives the car Exploits the computer/software
5 Definition of CS No real consensus (yet). A good definition that emphasizes the notion of “ algorithm ” is: CS is the study of algorithms including their: Formal and mathematical properties Hardware realizations Linguistic realizations Applications
6 Algorithm Informally: Effective and precise recipe to get the result for some problem: “ Recipe ” : Set of commands/instructions “ Effective ” : The result is obtainable after some time “ Precise ” : exactness, only understandable and doable commands
7 Simple Example for an algorithm “ Breakfast ” 1. Get a slice of bread 2. Butter it 3. Eat the buttered slice 4. If still hungry then resume from step 1, otherwise drink a cup of tea and stop.
8 Other examples for algorithms Backing a pie Using the telephone set Programming the VCR Doing tax calculation …
9 Summing up the first n integers … + n ? Algorithm 1. Get the number n 2. Set m to n+1 3. Set n to n multiplied by m 4. Divide n by 2 5. Display the result n
10 The Concept of Algorithm Inventor: Abu Jaafar Mohammed Ibn-Musa Al- Khawarizmi Arabic mathematician of the 8 th century Born in Khawarizm (Persia) Lived in Baghdad where he worked in Beitu Alhikma (House of Wisdom) under the Khalif Al-Maamoon. Wrote two famous books: One is a treatise on the calculation using Arabic numerals, his name was translated in Latin to Algorismus, from there the word algorithm. The other is even more famous since it introduced “ algebra ” as a new fundamental branch of mathematics. The book is Kitab Aljabr Wal Muqabala (Book of Restoration and Reduction) -> Aljabr had been translated to Algebra.
11 The Concept of Algorithm The main benefit of algorithms is that we can automate the solution for every problem we can find an algorithm for solving it. Formal definition of an algorithm: An algorithm is a well-ordered collection of unambiguous and effectively computable operations that when executed produces a result and halts in a finite amount of time.
12 The Concept of Algorithm Well-ordered collection We have to always know what to do next. Counterexample: 1. Get a slice of bread 2. Butter it 3. Eat buttered slice 4. Repeat -> 4 th step: repeat what? -> not an algorithm!
13 The Concept of Algorithm Unambiguous + effectively computable operations Operations: units of work the computer can do. Different levels of operations are possible: Example: “ Breakfast ” 1. Eat buttered bread until “ full ” 2. Drink a cup of tea 3. Stop -> Step 1 may be too “ high ” for a kid Step 1 is a sequence of (sub-)operations, it also forms an algorithm! Possible algorithm for Step 1: 1. Get a slice of bread 2. Butter it 3. Eat the buttered slice 4. If still hungry resume from 1
14 The Concept of Algorithm Operations should be unambiguous directly doable need not be further explained (e.g. using sub-operations) Unambiguous operations are also called primitives Any operation must be doable Unambiguous (understandable) but not doable operations are not welcome for algorithms Hence only effectively computable operations should be used
15 The Concept of Algorithm Examples of unambiguous but not effectively computable operations: List all positive numbers Divide by 0 Compute for ever Print the exact value of That produces a result Any algorithm should produce a result observable to the end user. Result may be: Answer Error message …
16 And halts in a finite amount of time Practically one of the most crucial properties of algorithms Algorithms that work well but cannot stop are useless Example: “ Endless Loop ” 1. Get a slice of bread 2. Butter it 3. Eat the buttered slice 4. Repeat from step 1 5. Drink a cup of tea 6. Stop Common flaw in the design of algorithms: Endless loops The Concept of Algorithm