1 / 20

An Introduction to Computer Science

Outline

- Misconceptions of Computer Science
- The Definition of Computer Science
- Algorithms
- Conclusion

Introduction

Misconceptions about CS (I)

- Computer Science is the study of computers
- Some earliest and most fundamental theoretical

work in CS took place during 1920 1940 (before

the development of computers) - Theoretical CS study the logical and

mathematical properties of problems and their

solutions (formal model) - CS is no more about computers than astronomy is

about telescopes, biology is about microscopes,

or chemistry is about beakers and test tubes.

Science is not about tools. It is about how we

use them, and what we find out when we do

Misconceptions about CS (II)

- Computer Science is the study of how to write

computer programs - Programming is a tool by which researchers can

study new ideas and build and test new solutions - When a computer scientist has designed and

analyzed a new approach to solving a problem or

has created a new way to represent information,

then he will implement that idea as a computer

program in order to test it on an actual computer

system - Permit researchers to see how well these new

ideas work and whether they perform better than

previous methods - How much memory and time is required?

Misconceptions about CS (II) (Cont.)

- Computer Science is the study of how to write

computer programs - In CS, it is not only the construction of a

high-quality program that is important, but also

the methods it embodies, the services it

provides, and the results it produces. - A program is only a means to an end, not an end

in itself - ????????
- ???????????,???????

Misconceptions about CS (III)

- Computer Science is the study of the uses and

applications of computers and software - Word, Excel?
- A lot of people use software, but
- Computer scientist is responsible for specifying,

designing, building and testing software packages

as well as the computer systems on which they run.

Definition of Computer Science

Computer Science

- Computer Science is the study of algorithms,

including - Their formal and mathematical properties
- Study the behavior of algorithms to determine

whether they are correct and efficient - Their hardware realizations
- Design and build computer systems that are able

to execute algorithms - Their linguistic realizations
- Design programming languages and translating

algorithms into these languages so that they can

be executed by the hardware - Their applications
- Identify important problems and design correct

and efficient software packages to solve these

problems

Whats An Algorithm?

Algorithm is everywhere, not only in CS

- Dictionary definition a procedure for solving a

mathematical problem in a finite number of steps

that frequently involves repetition of an

operation broadly a step-by-step method for

accomplishing some task - Informal definition an ordered sequence of

instructions (operations) that is guaranteed to

solve a specific problem - Step 1 Do something
- Step 2 Do something
- Step 3 Do something
- Step N Stop, you are finished

Operations

Operations in An Algorithm (I)

- A sequential operation carries out a single

well-defined task. When that task is finished,

the algorithm moves on to the next operation. - Add 1 cup of butter to the mixture in the bowl
- Set the value of x to 1
- A conditional operation is the question-asking

instructions of an algorithm. It asks a question

and then select the next operation to be executed

according to the question answer - If the mixture is too dry, then add 0.5 cup of

water to the bowl - If x is not equal to 0, then set y equal to 1/x

otherwise, print an error message that says we

cannot divide by 0

Operations in An Algorithm (II)

- An iterative operation is a looping instruction

of an algorithm. It tells us not to go on to the

next instruction, but, instead, to go back and

repeat the execution of a pervious block of

instructions - Repeat the previous two operations until the

mixture has thickened - Repeat steps 1, 2, and 3 until the value of y is

equal to 1

When you want to command a computer to execution

your algorithm, you have to convert your

algorithm into a programming language.

Algorithm for Programming Your VCR

Which instructions are sequential, conditional,

and iterative?

Algorithm for Adding Two m-Digit Numbers

Which instructions are sequential, conditional,

and iterative?

Algorithm for Adding Two m-Digit Numbers (Demo)

- Add (47 25)
- m2
- a14 a07
- b12 b05
- Step 1 carry0
- Step 2 i0
- Step 3 repeat 4-6, until i gt 1
- First iteration (i has the value 0)
- 4 Add (a0b0carry) ? c012
- 5 c0 gt 10 ? c02, carry1
- 6 Reset i to (01)1. Because i is not greater

than 1, go back to step 4

- Second iteration (i has the value 1)
- 4 Add (a1b1carry) ? c17
- 5 c1 lt 10 ? reset carry to 0
- 6 Reset i to (11)2. Because i is greater than

1, do not repeat but go to step 7 - Step 7 set c20 (cmcarry)
- Step 8 Print out the answerc2 c1 c0 072
- Step 9 Stop

??????,?????????

Algorithm for Adding Two m-Digit Numbers (Demo)

i 0carry 0

i 1carry 1

Step 7

c2carry0

1 0

1 0

Step 8

a 4 7 b 2 5

a 4 7 b 2 5

c2 c1 c0 072

2

c

2

c

7

c0a0b0carry75012 c0 gt 10 ?

c012-102 carry 1

c1a1b1carry4217 c1 lt 10 ? c1 does not

change carry 0

First Iteration (i0)

Second Iteration (i1)

Why Are Formal Algorithms So Important in CS?

- If we can specify an algorithm to solve a

problem, then we can automate its solution

(convert it into a program) - Computer Science ? the science of algorithmic

problem solving - Discover correct and efficient algorithms for a

wide range of interesting problems, studying

their properties, designing programming languages

into which those algorithms can be encoded, and

designing and building computer systems that can

automatically executed these algorithms in an

efficient manner

Conclusion

- Computer Science is the study of algorithms,

including - Their formal and mathematical properties
- Study the behavior of algorithms to determine

whether they are correct and efficient - Their hardware realizations
- Binary numbers, boolean logics, gates, and

computer organization (memory, cache, I/O, ALU,

Control) - Their linguistic realizations
- Programming Languages, Data Structures,

Object-oriented - Compiler
- Their applications
- Spreadsheet, computer networks, artificial

intelligence

Textbook Organization

- Introduction
- Part One Machine Architecture
- Data Storage
- Data Manipulation
- Part Two Software
- Operating Systems and Networks
- Algorithms
- Programming Languages
- Software Engineering

Textbook Organization (Cont.)

- Part Three Data Organization
- Data Structures
- File Structures
- Database Structures
- Part Four The Potential of Algorithmic Machines
- Artificial Intelligence
- Theory of Computation