Presentation is loading. Please wait.

Presentation is loading. Please wait.

ALGORITHMS CSC 171 LECTURE 1. What is “Computer Science”? What is “Science”? What is a “Computer”? What is “Computation”?

Similar presentations


Presentation on theme: "ALGORITHMS CSC 171 LECTURE 1. What is “Computer Science”? What is “Science”? What is a “Computer”? What is “Computation”?"— 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 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

5 ALGORITHM An algorithm is a procedure for solving problems in terms of : 1. The actions to be executed (statements) 2. 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.

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

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

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

9 Example: Finding square roots 1. Determine the value you want a square root of : call it “A” 2. Start with 1 : call it a “guess” 3. Divide “A” by the “guess” call the result “second_guess” 4. 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. 5. All done (your last guess is pretty good)

10 Square Roots g1=1 A=50 g2=50/1=50 g1=(1+50)/2=25.5 g2=50/25.5=1.96 g1=(25.5+1.96)/2=13.73 g2=50/13.73=3.641 g1=(13.73+3.641)/2= 8.68 g2 = 50/8.68=5.76 g1=(8.68+5.76)/2=7.22 g2=50/7.22=6.92 g1=(7.22+6.92)/2=7.07 g2=(50/7.07)=7.072 All done

11 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

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

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

14 The Containment Pattern Starts with some “begin” symbol – {([“ Ends with some “end” symbol – “])} General Pattern + +

15 Named containment + + + +


Download ppt "ALGORITHMS CSC 171 LECTURE 1. What is “Computer Science”? What is “Science”? What is a “Computer”? What is “Computation”?"

Similar presentations


Ads by Google