notes1 - CMPS 10 Introduction to Computer Science Lecture...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMPS 10 Introduction to Computer Science Lecture Notes Chapter 1: Introduction What is Computer Science? Some possible misconceptions are: The study of computers Programming and programming languages Applications software like MS word, Adobe Photoshop, etc. A widely accepted definition of computer science was given by Norman Gibbs and Allen Tucker: Computer Science is the study of Algorithms , especially their (1) Mathematical Properties : Correctness, Efficiency, Complexity (time and space) (2) Hardware Realizations : Logic Gates, Circuits, Architecture (3) Software Realizations : Programming and Programming Methodologies (4) Applications to Other Disciplines : Mathematics, Physics, Engineering, Business Items (1), (2), and (3) constitute a rough outline of this course. We will not cover item (4), which is vast. So what is an algorithm? Informal definition: a step-by-step procedure which solves (all instances of) some specific problem. Some simple examples are: a cake recipe, instructions for balancing your checkbook, instructions for filling out your tax return Example Consider the problem of adding two 3-digit numbers 493 617 +751 +945 1244 1562 More generally we consider the problem of adding two m-digit numbers, where 1 m . Input: 1 m and two m-digit numbers: 0 1 2 2 1 a a a a a m m K - - and 0 1 2 2 1 b b b b b m m K - - Output: Their sum: 0 1 2 2 1 c c c c c c m m m K - - 1) carry 0 2) 0 i 3) while m i < do 4-10 4) + + i i i b a c carry 5) if 10 i c do 6-7 6) 10 - i i c c 7) carry 1 8) else 9) carry 0 10) 1 + i i 11) m c carry 12)print 0 1 2 2 1 c c c c c c m m m K - - 13)stop
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Trace execution of this algorithm on: 3 = m , 6 2 = a , 1 1 = a , 7 0 = a , 9 2 = b , 4 1 = b , 5 0 = b . Note that the above operations can be classified into three types: (1) Sequential Perform a single task, then move to the next operation in the list. (2) Conditional (Branching) Select the next operation based value of a logical expression. (3) Iterative (Loop) Repeat some block of instructions until some condition is met. Why should we specify an algorithm in this way?
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2011 for the course CMPS 10 taught by Professor Tantalo during the Fall '08 term at UCSC.

Page1 / 4

notes1 - CMPS 10 Introduction to Computer Science Lecture...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online