Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computer Science

Similar presentations


Presentation on theme: "Introduction to Computer Science"— Presentation transcript:

1 Introduction to Computer Science
CS120: Week 1 Introduction to Computer Science Course Introduction Course overview Laboratory Sessions What is Computer Science? What is an algorithm? History of Computing

2 Course Overview Broad overview of Computer Science
Text Book: Schneider & Gersting An invitation to CS Selected Topics only Lab exercises alongside Lab Manual

3 Course Overview Course Objective Course Outline
Assessments and Grading Assessment schedule Variety of topics – Overview CS Lectures on Mondays & Fridays and Labs on Tuesdays.

4 Lab Exercises Of the 21 exercises, we will do some 10 only
Should attend the lab sessions Lab exercises will be checked Self paced (most could be completed in class) Have lab tutors to help you learn Concept (theory) followed by Lab Bring both the text-book and lab manual to the class

5 An Introduction to Computer Science
Objectives: Explain what computer science is and is not. Know and explain definitions of: algorithm, computing agent, and primitive. Trace execution of an algorithm. Determine if a set of steps is an algorithm; explain. Describe and identify sequential, iterative, conditional operations. Objectives:

6 What is Computer Science
Write down the things a computer has. Write down the things you do with a computer. Write down your definition of what computer science is

7 Computer Science is not just:
the study of computers programming using computer applications

8 Not just computers circuits disks monitors Keyboards Play stations
PDAs

9 Not just programming Using programming languages like Pascal
FORTRAN, COBOL COBOL C, C++, C# Java

10 Not just using applications
word processors spreadsheets databases Internet Web Browsers

11 Computer Science is the study of algorithms, including their
formal mathematical properties (correct, efficient) hardware realizations (to carryout) linguistic realizations (translate) Applications (uses) Memorize this definition and be able to explain it.

12 Organization of the Textbook
CHAPTER LEVEL 6 5 4 3 2 1 15 12, 13, 14 8, 9, 10, 11 6, 7 4, 5 2, 3 Social Issues Applications Software Virtual Machine Go through each, showing its relationship to previous definition. algorithms -- formal and mathematical properties hardware -- circuits etc..... virtual machine -- the machine we work with -- don’t wire boards etc.... software -- programs applications -- word processors, spreadsheets, Internet... social issues -- impact of computers on society Hardware Algorithmic Foundations

13 Completing the Loop So, for starters in CS, we learn about all the above six, starting from Algorithmic foundation We identify problems requiring solutions using computers for the good of the society. So there is the ‘Problem to be solved’ that links the ‘society’ and the ‘algorithmic foundation.’

14 What is an algorithm? Informally: An Algorithm is
a step by step method for solving a problem. (more formal definition later) We tell the computer how to do something and it does what we tell for us. So what does this imply? Use a shoe string laced through a card as a prop. Have students role play teaching a pre-schooler an algorithm for tying a shoe. As they do it have them try to explain each step verbally. e.g. 1. Take one end in each hand. 2. Bring left over right. 3. Loop left under right. 4. Pull ends until tight. 5. Make loop with right hand. 6. Hold loop with right and use left to bring other end around finger and loop, forming a hole next to the loop. 7. With left hand, push middle of string through the hold, forming another loop. 8. Grab the new loop with right hand. 9. Grab the old loop with the left hand. 10. Pull loops until tight.

15 Computing agent We do the algorithms
A thing that carries out the algorithm is called a computing agent. An unambiguous operation that can be understood and carried out by a computing agent is called primitive operation. When I tell you ‘Study Chapters 1 and 14 in our text for homework’, is it a primitive? How about ‘Build an airplane’?

16 Computing Agent The present day Computer Agent Can accept input
Can store information in and retrieve it from memory (unlike us accurately) Can take actions according to algorithm instructions (given to it) Can produce output

17 What is an Algorithm? Formal definition: An algorithm is a
well ordered collection of unambiguous and effectively computable operations that produces a result and halts in a finite amount of time. Go through each phrase, looking at their algorithm, talking about how it fits (or falls short of) this formal definition of an algorithm. Well order collection: steps must be done in certain order Unambiguous: can be understood and carried out without further explanation -- not too good on this -- must teach child the primitives. Effectively computable: can be done by the computing agent -- in this case, the preschooler. (Yes, it is possible -- since many preschoolers do it.) Produces a result: something gets done, even if not correct. Halts in a finite amount of time: e.g. if our algorithm ended with step 11 which said: pull both ends of the shoe string and repeat steps 5 through 11, would the algorithm halt? 1.When we design algorithms for the computer, how is it like teaching a preschooler to tie a shoe? How is it different? 2. What is the computing agent?

18 An Algorithm is Well Ordered
Each step of the algorithm is executed in the order in which it is written, or else the order is clearly stated. What is wrong with this algorithm to average two numbers? Step 1: Divide the sum by 2 Step 2: Add the two numbers

19 An Algorithm is Unambiguous
The algorithm must be clearly stated, in terms that the computing agent understands (its primitive operations). Correct this algorithm telling a robot how to take a step to the left, if its only primitive operations are Move_Forward_One_Step, and Turn_Right. Step 1. Turn left Step 2. Move_Forward_One_Step

20 An Algorithm is Effectively Computable
It must be possible for the computing agent to perform the operation and produce a result. What is wrong with this algorithm, if the computing agent can only work with real numbers? Step 1. Add 2 and –2. Step 2. Divide 4 by the result of Step 1.

21 An Algorithm Must Halt in a Finite Amount of Time
Even if it would take centuries to finish executing the algorithm, there is some point in time when the result would be produced. What is wrong with this algorithm? Step 1. Set X to –1 Step 2. Subtract 1 from X Step 3. If X is not 0, go back to Step 2.

22 Problems -- Are these algorithms? Why or why not?
Primitives for a robot are: move (take one step forward) and turn left. Algorithm? : move; move; turn left; move; turn right; move Primitives for a computer: decimal arithmetic operations, including finding square roots. Are these algorithms: Subtract Y from X; Take square root of result. Set X to -1; Repeatedly subtract 5 from X until X = 0. Each one breaks some part of definition of algorithm -- which part? 1. No. Ambiguous. Turn right must be further defined as? (turn left, turn left, turn left) 2. No. Not effectively computable when Y > X. 3. No. Does not Halt.

23 Three different things to be done
I have three research papers to do in CS120 On Saturday, if it rained I play some indoor games otherwise play an outdoor game. I am taking five courses this semester and in each course there are several assessments (exams, projects, research papers et.). I have a calendar sheet with dates & time for the whole semester. I want to mark on it the assessment dates (due dates, in some cases) Help me draw diagrams to describe these.

24 More about Algorithms The order in which the steps of an algorithm are executed is one of the following: sequential conditional iterative

25 Sequential Order Each step is performed in the order in which it is written (top to bottom). Example: Algorithm for finding a sale price. Step 1. Multiply the regular price by the discount percent. Step 2. Subtract the result of Step 1 from the regular price. Write the sequential algorithm for the computer on the board. Assume the computer can do the following primitive operations: add two numbers divide a number by another non-zero number remember a number print a number Trace with numbers 2, 6, 10. What does the algorithm do? 1. Add two numbers and remember the sum. 2. Add a third number to the sum. 3. Divide the sum by 3 and remember the result. 4. Print the result. Check this against the definition of an algorithm. Note that it is sequential.

26 Conditional Order Determines whether or not a condition is true; and, based on whether or not it is true, selects the next step to do. Example-- Algorithm for processing a bank check: Step 1. Determine if the amount of the check is greater than the checking account balance. Step 2. If Step 1 is true, print “Overdraft” Step 3. Otherwise, subtract the amount of the check from the balance. Write the conditional algorithm for the computer on the board. Same primitives as before plus the following: compare the value of two numbers to see if they are equal add two numbers divide a number by another non-zero number remember a number print a number Trace with inputs: 12,3 1,2 17,0 1. If the second number is not zero, then do the remaining steps. Divide the first number by the second and remember the result. Print the result. Why is the conditional operation necessary?

27 Iterative Operation Repeat a set of steps over and over -- also called a “looping” operation. Example: Algorithm for counting the digits in a positive integer N. Step 1. Set the Count to 0 Step 2. Divide N by 10 (dropping any remainder) Step 3. Add 1 to the Count Step 4. If N is greater than 0, repeat steps 2-4

28 Tracing steps in an algorithm
Trace the steps of the algorithm given in Figure 1.2 (page 7) in the text. There are nine steps. It has sequential, conditional and iterative – the three primitive – operations. Use the handout to trace the steps.

29 Trace Algorithm, Fig. 1.2 Step m i Carry a1 a0 b1 b0 c2 c1 c0 2 9 5 4
2 9 5 4 3

30 Trace Algorithm; C = A + B
Step: i : Carry: C2 : C1 : C0 : Next S: a1 = 9; a0 = 5; b1 = 4; b0 = 3; m = 2

31 Trace Algorithm; C = A + B
Step: i : Carry: C2 : C1 : C0 : Next S: a1 = 9; a0 = 5; b1 = 4; b0 = 3; m = 2

32 Trace Algorithm; C = A + B
Step: 8 9 i : 2 Carry: C2 : C1 : C0 : Next S: Halt a1 = 9; a0 = 5; b1 = 4; b0 = 3; m = 2

33 Steps _Tracing Step 1: carry = 0 (NS is 2) Step 2: set i = 0 (NS is 3)
Step 3:First loop steps 4-6 with i=0 (NS is 4 Step 4: Add 5+3+carry C0 = 8(NS is 5) Step 5: Because C0 is < 10, C0 = 8 and carry = 0 (NS is 6) Step 6: Reset i to (0+1) = 1 (NS is 3)

34 Steps _Tracing (cont) Step 3:Second loop steps 4-6 with i = 1 (NS is 4) Step 4: Add 9+4+carry C1 = 13 (NS is 5) Step 5: Because C1 is > = 10, C1 = 3 and carry = 1 (NS is 6) Step 6: Reset i to (1+1) = 2 (NS is 3)

35 Steps _Tracing (cont) Step 3: Now i > 1, so stop repeating steps 4-6 and go to the step just after the loop -which is step 7. (NS is 7) Step 7: Set c2 = 1 (NS is 8) Step 8: Print out C2, C1, C0 (NS is 9) Step 9: Stop.

36 1.4 Historical Overview of Computer Systems Development

37 The Nineteenth Century Inventor of Computers
Charles Babbage ’s idea for a general purpose steam-driven computer programs stored on punched cards four subsystems: memory, mill (ALU), operator (control unit), output programs documented by Ada Augusta, Countess of Lovelace (first programmer) Video: 00:00-10:20

38 The Birth of Computers 1940-1950
In the United States, the ENIAC was built at the University of PA by J. Presper Eckert and John Mauchly funded by Defense Department for use in World War II completed in 1946 contained 18,000 vacuum tubes and weighed 30 tons Video: 10:20-16:24

39 1950 - Present First Generation: 1950-1959
Second Generation: Third Generation: Fourth Generation: Fifth Generation: 1985-present

40 First Generation 1950-1959 UNIVAC: first commercial computer in US
started by Eckert and Mauckly sold to Remington Rand made famous by predicting Eisenhower landslide IBM 650: got a late start (1953) but captured the market away from UNIVAC Video: 16: :00

41 Second Generation 1959-1965 vacuum tubes replaced by transistors
difficulties of programming computers overcome by high level languages FORTRAN (Formula Translation) COBOL (Common Business Oriented Language 29: :57

42 Third Generation 1965-75 wiring problems solved by integrated circuits
first small computers built and sold to government on-board computer for Apollo first man on moon on-board computers for guided missiles 35: :13

43 Fourth Generation microprocessors -- allowed mass production of “throw-away” computers -- “computer on a chip” Apple (1978) -- first affordable commercial microcomputer IBM-PC (1981) -- took major part of market away from Apple Macintosh (1984) -- first graphical interface Microsoft Windows for IBM-PC (1990) 44: :59

44 Fifth Generation 1985-Present
Networked computers (the Internet) Versatile input-output (e.g. touch, speech) Multi-media (graphics and sound) Virtual reality (3-d graphics) Artificial intelligence Neural networks 57:59 - end


Download ppt "Introduction to Computer Science"

Similar presentations


Ads by Google