Presentation is loading. Please wait.

Presentation is loading. Please wait.

ALGORITHMS CSC 171 LECTURE 1.

Similar presentations


Presentation on theme: "ALGORITHMS CSC 171 LECTURE 1."— Presentation transcript:

1 ALGORITHMS CSC 171 LECTURE 1

2 What is “Computer Science”?
What is “Science”? What is a “Computer”? What is “Computation”?

3 Computer Science Is Computer Science, “science”?
Is computation part of nature? Is information part of nature? How do we study computation?

4 Computational Science
A mode of scientific investigation that includes several phases : Development of a mathematical model (equation) of some physical phenomenon or system Development of an algorithm to solve the model Implementation of the algorithm in software Simulation of the phenomenon using software Graphical visualization of the results Interpretation and validation of the results, which may lead to refinement of the original model and repetition of the cycle

5 History Muhammad ibn Musa Al'Khowarizmi (ca. 825)
Described rules to be followed for arithmetics using Hindu numerals. A written process to be followed to achieve some goal Translated into Latin in 1202 by Leonardo Fibonacci

6 ALGORITHM An algorithm is a procedure for solving problems in terms of : The actions to be executed (statements) The order in which these actions are executed Algorithms are independent of any specific computer language which may be used to for their implementation. Often expressed informally as pseudocode.

7 Some Algorithms How do I get to the pit? Your classmate Your parents
A robot Move forward x meters Turn right y radians

8 Abstraction To one computer: x = y + 5 To another:
Load y in accumulator Load 5 in register A Add register 5 to accum Store accum in x

9 Statements What do we need for “Statements” Syntax Semantics
the form in which statements may be written Semantics “meaning” attached to syntactic constructs

10 Example Syntax Semantics F = (9/5) * C + 32 2 F 3=+)C 9 * / 5(
Take the Celsius temperature Multiply it by 1.8 Add 32 The result is the Fahrenheit temperature

11 Example: Finding square roots
Determine the value you want a square root of : call it “A” Start with 1 : call it a “guess” Divide “A” by the “guess” call the result “second_guess” If guess is not close to second_guess, then set your guess to the average of guess and second guess and go to step 3. All done (your last guess is pretty good)

12 Square Roots g1=1 A=50 g2=50/1=50 g1=(1+50)/2=25.5 g2=50/25.5=1.96
All done

13 Language What does language do? Transfer information (describe)
Action oriented languages (directions) Functional languages Area = Pi * Radius * Radius Object oriented languages “model” the world around us

14 Computer Languages To a human we might say: To a computer we might say
Write: “Hello, CSC 171” To a computer we might say System.out.println(“Hello, CSC 171”);

15 History 1612 Napier invented and decimal points and logarithms.
1622 William Oughtred created the slide rule

16 History 1622 William Oughtred created the slide rule

17 A Computer Program public class myFirstProgram {
public static void main(String args[]){ System.out.println(“Hello, CSC171”); }

18 Programs in General Programs contain 3 types of things
Comments – notes to humans Headers – references to other code Code – instructions to humans

19 The Containment Pattern
Starts with some “begin” symbol {([“ Ends with some “end” symbol “])} General Pattern <begin>+<contents>+<end>

20 Named containment <header> + <containment>
<header> + <begin>+<contents>+<end> Often used as a mechanism of abstraction

21 The sequence pattern A sequence is a list of one or more instructions to be followed in order Sequence can be empty or Sequence can be <instruction> + ; + <sequence> <instruction> + ; + <instruction> + ; + <sequence> Etc; Robot example – complex instructions

22 Objects A class of things are objects with similar attributes
Objects are instances of a class A class is a general description of an object A “cookie cutter” defines a class of cookies An “cookie” is object Rubber stamp

23 myFirstProgram.java Contains a class definition, which contains
A “method” named “main”, which contains An instruction to the System.out object The instuction is a comand to print something That something is a String of characters “Hello, CSC171” is a data item


Download ppt "ALGORITHMS CSC 171 LECTURE 1."

Similar presentations


Ads by Google