14/07/2024
Chapter 00
An Introduction
CIVL1000
Computer Science
Instructor: Miguel Gomes da Costa Junior
Chapter 0: Introduction
• Computer science is the discipline that seeks to build a scientific
foundation for such topics as computer design, computer
programming, information processing, algorithmic solutions of
problems, and the algorithmic process itself.
• Computer science provides the underpinnings for today’s computer
applications as well as the foundations for tomorrow’s computing
infrastructure.
1
14/07/2024
Chapter 0: Introduction
• 0.1 The Role of Algorithms
• 0.2 The History of Computing
• 0.3 The Overarching Themes of Computer Science
01. The Role of Algorithms
This Photo by Unknown Author is licensed under CC BY-NC-ND
2
14/07/2024
01. The Role of Algorithms
An Informal Introduction
Algorithm: Program:
A set of steps Programming A representation
that defines The process of of an algorithm.
how a task is developing a program
performed.
Software: Programs and algorithms
Hardware: Equipment / Machinery
01. The Role of Algorithms
History of Algorithms
• The study of algorithms was originally a subject in mathematics.
Figure 0.2
• Early examples of algorithms
• Long division algorithm
• Euclidean Algorithm
• Gödel's Incompleteness Theorem: any complete study of our
arithmetic system lies beyond the capabilities of algorithmic activities.
3
14/07/2024
Figure 0.3
02. The History of Computing
• Early computing devices
• Abacus: positions of beads represent numbers
Abacus
• Gear-based machines (1600s-1800s)
• Positions of gears represent numbers
• Blaise Pascal, Wilhelm Leibniz, Charles Babbage
Pascaline – by Blaise Pascal
02. The History of Computing
Early Data Storage
• Punched cards
• First used in Jacquard Loom (1801)
• to store patterns for weaving cloth
Punched card
• Storage of programs in Babbage’s engine
• U.S. census process by Herman Hollerith
• Led to creation of IBM
• Popular through the 1970’s
• Gear positions
Babbage’s calculating machine
4
14/07/2024
02. The History of Computing
Early Computers
• Based on (electronically controlled) mechanical relays
• 1940: Stibitz at Bell Laboratories
• 1944: Mark I: Howard Aiken and IBM at Harvard
• Based on vacuum tubes
• 1937-1941: Atanasoff-Berry at Iowa State
• 1940s: Colossus: secret German code-breaker
• 1940s: ENIAC: Mauchly & Eckert at U. of Penn.
This Photo by Unknown Author is licensed under CC BY-NC
Vacuum tubes
02. The History of Computing
Figure 0.4
Three women operating
the ENIAC’s main control
panel
10
10
5
14/07/2024
02. The History of Computing
Personal Computers
• Hobbyists built homemade computers
• Apple Computer established in 1976.
• IBM introduced the PC in 1981.
• Accepted by business
• Became the standard hardware design for most
desktop computers
• Most PCs use software from Microsoft
This Photo by Unknown Author is licensed under CC BY
11
11
02. The History of Computing
End of the 20th Century
• Internet revolutionized communications
• World Wide Web by Tim Berners-Lee
• Search Engines such as Google or Microsoft
• Miniaturization of computing machines
• Embedded (GPS, in automobile engines)
• Smartphones This Photo by Unknown Author is licensed under CC BY-SA-NC
12
12
6
14/07/2024
0.3 The Overarching Themes of Computer Science
• Computing technology is
fundamental to being a Algorithms
part of the modern world.
Impact Abstraction
• Seven “Big Ideas” that Computer
unite computer science: Science
Internet Creativity
Programming Data
13
13
0.3 The Overarching Themes of Computer Science
Algorithms
Figure 0.5
• CS is the science of algorithms
Limitations of
• Draws from other subjects,
Application of Execution of including
• Mathematics
Algorithms • Engineering
Analysis of Communication of • Psychology
• Biology
• Business Administration
Discovery of Representation of • Linguistics
14
14
7
14/07/2024
0.3 The Overarching Themes of Computer Science
Abstraction
• Abstraction: The distinction between the B
A
external properties of an entity and the details
of the entity’s internal composition
• Abstract tool: A “component” that can be used
without concern for the component’s internal
properties B
A
15
15
0.3 The Overarching Themes of Computer Science
Creativity
• Computer science is inherently creative
• Discovering and applying algorithms is a
human activity
• Extends existing forms of expression
• Enables new modes of digital expression
• Creating large software systems is like
conceiving a grand new sculpture
16
16
8
14/07/2024
0.3 The Overarching Themes of Computer Science
Data
• Computers can represent any information
that can be discretized and digitized
• Algorithms process and transform data
• Search for patterns
• Create simulations
• Generate knowledge and insight
• Data is driving modern discovery
17
17
0.3 The Overarching Themes of Computer Science
Programming
• Programming is referred to as:
• Translating human intentions into
executable algorithms
• Computer hardware is capable of
only simple algorithmic steps
• But abstractions in a programming
language allow humans to reason and
encode solutions to complex problems
18
18
9
14/07/2024
0.3 The Overarching Themes of Computer Science
Internet
• Profound impact in the way information is:
• Stored
• Retrieved
• Shared
• Privacy
• Security
19
19
0.3 The Overarching Themes of Computer Science
Impact
• Social, ethical, legal impacts including:
• Security concerns
• Issues of software ownership and
liabilities
• Social impact of database technology
• Consequences of artificial intelligence
20
20
10
14/07/2024
Introduction to Computers
21
What is a Computer?
• A computer consists of a CPU, memory, storage devices, input and
output devices, and communication devices.
BUS
Storage Input and Output Communication
CPU Memory
Devices Devices Devices
22
22
11
14/07/2024
Central Processing Unit (CPU)
• The “brain” of a computer. It retrieves instructions from memory and
executes them. Two components:
• Control Unit and Arithmetic and Logical Unit (ALU).
• Every computer has an internal clock, which emits electronic pulses at
a constant rate.
• These pulses are used to control and synchronize the pace of operations.
• Measure in hertz (Hz), with 1 Hz = 1 pulse per second.
• Clock speed is now usually stated in gigahertz (GHz).
BUS
Storage Input and Output
CPU Memory Communication Devices
Devices Devices
23
23
How is Data Stored?
• Computers are digital devices, and they can only understand two
stable states: on (1) and off (0), like a series of switches.
• 0s and 1s represent the digits in the binary system and are called bits.
• Numbers and characters are encoded in bytes. A byte is a set of eight bits. A
byte is the minimum storage unit.
• The encoding and decoding of data is performed automatically by the
computer system based on the encoding scheme.
• Most schemes translate each character into a predetermined string of bits such
as EBCDIC, ASCII or Unicode (e.g. UTF-8).
0 1 0 0 0 0 1 1
The letter ‘C’ represented in ASCII encoding scheme.
24
24
12
14/07/2024
ASCII - American Standard Code for Information Interchange
25
25
BUS
Memory CPU Memory
Storage Input and Output Communication
Devices Devices Devices
• Computer’s memory consists of an ordered sequence of bytes for
storing programs as well as their working data.
• A program and its data must be brought to memory before execution.
• A memory byte is never empty, but its initial content may be
meaningless to your program.
• The current content of a memory byte is lost whenever new information is
placed in it.
• Today’s computers usually have at least 8 GB of RAM.
• Generally, we could say that “the more RAM has, the faster it can operate”, but
there are limits to this simple rule.
26
26
13
14/07/2024
BUS
Memory CPU Memory
Storage Input and Output Communication
Devices Devices Devices
• Every byte in the memory has a unique address, and it is used to
locate the byte for storing and retrieving the data.
• Since the bytes in the memory can be accessed in any order, the
memory is also referred to as random-access memory (RAM).
Memory address Memory content
. .
2000 01000011 Encoding for character ‘C’
2001 01110010 Encoding for character ‘r’
2002 01100101 Encoding for character ‘e’
2003 01110111 Encoding for character ‘w’
2004 00000011 Encoding for number 3
. .
27
27
Storage Devices
• RAM is a volatile form of data storage since information is lost when the
power is off.
• Programs and data are permanently stored on storage devices and are
moved to memory when the computer uses them.
• There are three main types of storage devices:
• Magnetic disk drives (Hard disks)
• Optical storage devices (CD and DVD)
• Flash memory devices (SSD, USB flash drive)
BUS
Storage Input and Output Communication
CPU Memory
Devices Devices Devices
28
28
14
14/07/2024
Input and Output Devices
• Input and output devices let the user communicate with the computer.
• Input devices include keyboards, mice, scanners, microphones, joysticks, and
stylus.
• Output devices include monitors, speakers, headphones, printers, and
projectors.
• Input/output devices include touchscreens, CD/DVD drives, and USB/Flash
drives.
BUS
Storage Input and Output Communication
CPU Memory
Devices Devices Devices
29
29
Communication Devices
• Computers can be networked through communication devices, such as:
• a dialup modem (modulator/demodulator) uses a standard phone line.
• a DSL (digital subscriber line) – also uses a standard phone line.
• a cable modem uses a TV cable line.
• network interface card (NIC) is a device to connect a computer to a local area network (LAN).
• Wireless networking is now extremely popular. Laptop computers today are
equipped with a wireless adapter that enables the connection to a LAN and the
Internet.
BUS
Storage Input and Output Communication
CPU Memory
Devices Devices Devices
30
30
15
14/07/2024
Writing a Simple Program
• Writing a program involves designing algorithms and translating them
into programming instructions, or code.
• An algorithm describes how a problem is solved by listing the actions
that must be taken, the order of their execution, and how it
terminates.
• Algorithms can help the programmer plan a program before writing it in a
programming language.
• Algorithms can be described in natural languages or in pseudocode (natural
language mixed with some programming code), or in formulas (mathematical
equations), or in a flowchart (diagrams with symbols).
31
31
Pseudocode
• A pseudocode is a plain language
description of the steps in an Calculate the area of a circle
algorithm or another system.
1. Input the radius
2. Compute area = radius * radius*
3. Output the area
32
32
16
14/07/2024
Flowchart
Symbol Meaning • A flowchart is a diagram that describes Start
Start/End an algorithm or process, showing the
(terminal) steps as boxes of various kinds, and Input
Input/Output their order by connecting these with radius
arrows.
area =
Process
• Read from top to down and left to right. radius*radius*
Decision • As follows some symbols used in
flowcharts. Output
Flow lines area
Subprogram
End
Connector
Example of Calculate the area of a circle
33
33
Programming Languages
• Computer programs, known as software, are instructions that tell a
computer what to do.
• Computers do not understand human languages; so, programs must
be written in languages computers can understand.
• Programming languages were developed to make the programming
process easier to people.
• However, all programs must be converted into instructions that computer can
execute.
34
34
17
14/07/2024
Programming Languages
• Machine language is a set of primitive instructions built into every
computer.
• These instructions are in the form of binary code.
• Assembly language is a low-level language developed to make
programming easier.
• A mnemonic is used to represent each machine-language instruction.
• Assembler is the program used to translate assembly-language programs into
machine code.
… …
Add 2, 3, result Assembler 1101101010011010
… …
Assembly Source File Machine-Code File
35
35
Programming Languages
• High-level languages are English-like and easy to learn and use.
• The instructions are called statements, and the programs are called source
program/source code.
• An interpreter or a compiler is used to translate the source program into
machine code for execution.
• An interpreter translates and executes a program one
statement at a time.
• A compiler translates the entire source program into a machine-language file for execution.
36
36
18
14/07/2024
Popular High-Level Languages
• COBOL (COmmon Business Oriented Language)
• FORTRAN (FORmula TRANslation)
• BASIC (Beginner All-purpose Symbolic Instructional Code)
• Pascal (named for Blaise Pascal)
• Ada (named for Ada Lovelace)
• C (whose developer designed B first)
• Visual Basic (Basic-like visual language developed by Microsoft)
• Delphi (Pascal-like visual language developed by Borland)
• C++ (an object-oriented language, based on C)
• Java (a popular object-oriented language, similar to C++)
• C# (a Java-like developed my Microsoft)
• Python
•…
37
37
Programming Style and Documentation
• Appropriate Comments
• Proper Indentation and Spacing Lines
• Block Styles 1. # Calculate the area of a circle
2.
3. # Input the radius
4. radius=float(input("Input the radius: "))
5.
6. # calculate the area
7. pi = 3.1415926535897932
8. area = radius**2 * pi
9.
10. # Output the area
11. print("The area of the circle is", area)
38
38
19
14/07/2024
Programming Errors
• Syntax Errors
• Errors that are detected by the compiler (also called compile errors).
• Runtime Errors
• Errors that cause a program to terminate abnormally.
• Logic Errors (or Semantic Errors)
• Errors that occur when a program does not perform the way it was intended.
39
39
Operating Systems (OS)
• The operating system is a program that manages
and controls a computer’s activities.
• Popular operating systems for general-purpose
computers are Microsoft Windows, Mac OS, and Linux.
• Application programs such as an Internet browser and
a word processor cannot run without an operating
system.
40
40
20