You are on page 1of 72

CS111 | COM101 Intro.

to Computer Science
Computer Science Dept.
Helwan University

Lecture 1
Computational
Thinking – Part 1
1.1 Computers & Computer Science
 What is a Computer? – The Evolution of
Computers. – Computer Science? – Informatics?
1.2 Binary versus Decimal Numeral System
1.3 Representation Faculty of
 ASCII & UNICODE – RGB, Pixels, Videos, & Audio Computers &
– Computer Graphics / Vision, Image & Signal Artificial Intelligence
Processing. FALL 2023
Where are we now .. ?!
0: Course Introduction & Plan
1: Computational Thinking – Part 1 (Computers, Computer Science, & Binary Representation)
2: Computational Thinking – Part 2 (Types of Hardware, Algorithms, & Programming
Languages)
3: Computational Thinking – Part 3 (Types of Software, Basics of Programs, & Compilation)
4: Variables, Constants, & Data Types in C
5: Arithmetic & Bitwise Operations, Logical & Relational Operators, and Precedence
6: Control Structures – Selection (Decisions)
7: Control Structures – Repetition (Loops)
8: C Built-In Functions & Solved Examples (1st Set)
9: User–Defined Functions & Scope of Variables
10: Number Systems, Binary Arithmetic, & the Complements Representation
11: Recursion, Function Overloading, & Call-by-Reference versus Call-by-Value
12: Solved Examples (2nd Set)

Course & Lectures are based on their counterparts in the following:


o Harvard University's CS50; An introduction to the intellectual enterprises of computer science and the art of
programming, Harvard School of Engineering and Applied Sciences.
o UNSW's CS1: Higher Computing, by Richard Buckland – The University of New South Wales.
o MIT's 6.087 Practical Programming in C (2010), 6.096 Introduction to C++ (2011), and 6.S096 Introduction to C and
C++ (2013), MIT (Massachusetts Institute of Technology) OpenCourseWare.
Lecture 1: Computational Thinking – Part 1
1.1 Computers & Computer Science
 What is a Computer?

 The Evolution of Computers

 Computer Science?

 Informatics?

1.2 Binary versus Decimal Numeral System

1.3 Representation
 ASCII & UNICODE

 RGB, Pixels, Videos, & Audio

 Computer Graphics, Computer Vision, Image & Signal Processing


What is a Computer?
 The term computer is derived from the word compute; that
is, to calculate.
 A computer is .. a programmable, electronic device that
accepts data (input), performs operations on that data
(processing), and stores the data (storage) or results (output)
as needed. Thus, these are a computers basic operations.
 Computers follow instructions, called programs, which
determine the tasks the computer will perform.

4
The Evolution of Computers
George Boole; Invented
Ismail al-Jazari; Ada Lovelace;
Boolean logic, the basis of
Invented the first Writer of the world's modern digital computer
programmable first computer program. logic.
humanoid robots
in 1206.

Alan Turing; Father of


theoretical computer
science and artificial
5
intelligence.
Computer Science?
- Computer science is the study of computation and information.
- Computer science is fundamentally problem-solving.
- We can think of problem-solving as the process of taking some
input (details about our problem) and generate some output (the
solution to our problem). The “black box” in the middle is
computer science.
Computer
Science
input → → output

6
Computer Science?
o Data; Raw, unorganized facts (can be in the form of text,
graphics, audio, or video).
o Information; Data that has been processed into a meaningful
form.
o Information Processing; Converting data into information

Information
Processing
data → → information
(data + meaning)
7
Computer Science?
Its fields can be divided into various theoretical and practical disciplines.
Programming
Computer Concepts & Data Structures Algorithms Databases
Languages
Science Data/Digital
Parallel &
Operating Computer Communication
Distributed
Systems Architecture & Computer
Computation
Networks

Computer Human– Digital Signal &


Software
Security & Computer Image
Engineering
Cryptography Interaction Processing

Artificial
Computer Computer Intelligence &
Robotics
Graphics Vision Machine
Learning

Statistics Linear Algebra Discrete Math ..


8
Informatics?
o " .. Scientific progress increasingly depends on our ability to
harness and apply tools and techniques from the computer
and information sciences."
o " .. This application of methods from the computer and
information sciences in other fields of science is not just a
happy accident; it is also a field in its own right — one
commonly referred to as informatics."
o " .. Prefix that term with – usually – a Greek root or two and
you get terms like bioinformatics, neuro-informatics, psycho-
informatics, and ecoinformatics, all are well-established
subfields responsible for many of the most exciting recent
discoveries in their parent disciplines."
Psychoinformatics: New Horizons at the Interface of the Psychological and Computing Sciences - Tal Yarkoni - Current Directions in
Psychological Science 2012 21: 391 - DOI: 10.1177/0963721412457362 9
Informatics?
Examples:
o Psycho-informatics; "an emerging [research] discipline that uses tools and
techniques from the computer and information sciences to improve the
acquisition, organization, and synthesis of psychological data."
o Ecoinformatics (a.k.a. ecological informatics); the application of
computer/information science in Ecology and Environmental science.
o Business Informatics (BI); a discipline combining economics, business
administration, information technology, and concepts of computer science.
o Geographic Information Science (GIScience / GISc); a discipline that studies the
techniques to capture, represent, process, and analyze geographic information
(using Geographic Information Systems "GIS", which are software tools).
o Engineering Informatics; the study of use of information and the design of
information structures that facilitate the practice of engineering.
o Astroinformatics; a field of study involving the combination of astronomy, data
science, machine learning, informatics, and communications technologies.
o Disaster Informatics (a.k.a. Crisis informatics); the study of the use of
information & technology in the preparation, mitigation, response, and
10
recovery phases of disasters and other emergencies.
Informatics?
More Examples:
o Health informatics; is a field that concerns the generation, processing, storage,
and use of health-related data, information, and knowledge. There is a great
diversity in the sub-disciplines of health informatics, including:

Health Informatics
Biomedical Medical Clinical
Bioinformatics
Informatics Informatics Informatics

Nursing Pharmacy Public Health


..
Informatics Informatics Informatics

11
Exercises
What have we learned?

 What is a computer? And what


is Computer Science?
 What’s the difference between
data and information?
 Mention 5 computer science
disciplines (fields).
 Define informatics.
Up Next ..
Additional Section 1.2
Resources
 What is Computer Science (in Arabic):
https://ar.wikipedia.org/wiki/‫علم_الحاسوب‬

 Lecture 1 | MIT 6.00 Introduction to Computer


Science and Programming, Fall 2008 (in English):
https://www.youtube.com/watch?v=k6U-
i4gXkLM
Lecture 1: Computational Thinking – Part 1
1.1 Computers & Computer Science
 What is a Computer?

 The Evolution of Computers

 Computer Science?

 Informatics?

1.2 Binary versus Decimal Numeral System

1.3 Representation
 ASCII & UNICODE

 RGB, Pixels, Videos, & Audio

 Computer Graphics, Computer Vision, Image & Signal Processing


Why the Binary Representation?

We need a way to represent inputs and


outputs, such that we can store, work-with,
& display information in a standard way.

15
Decimal Vs. Binary
Number Systems

16
When we first learned to count, we might have
used one finger to represent one thing. That
system is called unary.

When we learned to write numbers with the


digits 0 through 9, we learned to use decimals
(Arabic numeral system):

0123456789
17
Digital devices understand only two different
states: ON and OFF ..

💡💡
01

18
Why does the following represent
one hundred and twenty-three?

123

19
1
The 3 is in the ones column.
123
10
The 2 is in the tens column.
123
100
And ..
The 1 is in the hundreds column.
123
20
Each place for a digit represents a power of ten,
since there are ten possible digits for each place.

100 10 1

123
100 × 1 + 10 × 2 + 1×3

21
100 10 1 100 10 1

000 006
001 007
002 008
003 009
004 ….?
005 22
100 10 1 100 10 1

000 006
001 007
002 008
003 009
004 010
005 23
In binary, with just two digits, we have powers of
two for each place value:

4 2 1

000

24
So, Decimal (powers of 10) ..

102 101 100

000
.. versus Binary (powers of 2).

22 21 20

000 25
Counting in Binary ..

4 2 1

000

26
Counting in Binary ..

4 2 1

001

27
Counting in Binary ..

4 2 1

010

28
Counting in Binary ..

4 2 1

011

29
Counting in Binary ..

4 2 1

100

30
Counting in Binary ..

4 2 1

101

31
Counting in Binary ..

4 2 1

110

32
Counting in Binary ..

4 2 1

111

33
How can we represent 8 in binary?

34
Binary makes sense for computers because we
power them with electricity, which can be either on or
off, so each bit only needs to be on or off.

💡
bit
In a computer, there are millions, or billions of
switches called transistors that can store electricity
and represent a bit by being “on” or “off”.

35
With enough bits, or binary digits, computers can
count to any number.

💡💡💡💡💡💡💡💡
bit bit bit bit bit bit bit bit
byte
8 bits make up one byte.

36
What is the value of the following
byte?

💡💡💡💡💡💡💡💡

37
Binary Data Representation:
Computer memory is normally represented in terms of Kilobytes or
Megabytes. In the Metric System, one Kilo represents 1000 grams,
that is 103. In the Binary System, one Kilobytes represent 1024 bytes,
that is 210.
The following table shows the representation of various memory
sizes: Name Abbreviation Size (in bytes)
Kilo K 210
Mega M 220
Giga G 230
Tera T 240
Petta P 250
Exa E 260
Zetta Z 270
Yotta Y 280
Exercises
What have we learned?

 Define the Decimal and Binary number systems, and


the differences between them.
 How can we represent the following decimal values
in binary: 2, 3, 7, 8, 50, 60, 100, 127, 128, 255, 256.
Up Next ..
Additional Section 1.3
Resources
 What is a binary number (in Arabic):
https://ar.wikipedia.org/wiki/‫نظام_عد_ثنائي‬

 Why Do Computers Use 1s and 0s? Binary and Transistors


Explained (in English):
https://www.youtube.com/watch?v=Xpk67YzOn5w

 How exactly does binary code work? [TED-Ed]


(in English):
https://www.youtube.com/watch?v=wgbV6DLVezo
Lecture 1: Computational Thinking – Part 1
1.1 Computers & Computer Science
 What is a Computer?

 The Evolution of Computers

 Computer Science?

 Informatics?

1.2 Binary versus Decimal Numeral System

1.3 Representation
 ASCII & UNICODE

 RGB, Pixels, Videos, & Audio

 Computer Graphics, Computer Vision, Image & Signal Processing


Once more .. Why the Binary Representation?

We need a way to represent inputs and outputs,


such that we can store, work-with, & display
information in a standard way.

42
- ASCII & UNICODE
To represent letters, all we need to do is decide how
numbers map to letters. Some humans, many years
ago, collectively decided on a standard mapping
called ASCII (stands for American Standard Code for
Information Interchange). It's a 7-bit character code
where every single code represents a unique
character.

A
The letter “A”, for example, is the number 65, and
“B” is 66, and so on.
44
A
ASCII 65
1000001
45
... A B C D E F G H I ...

ASCII
... 65 66 67 68 69 70 71 72 73 ...

46
The mapping includes upper and lowercase Latin
alphabet, the numbers 0-9, and some extra
characters (punctuation and other symbols).

47
The first thirty-two codes (0 to 31) in ASCII are reserved for
control codes that control computer equipment (such as
printers). For example, code 10 represents the "line feed"
function (which causes a printer to advance its paper). Table 1
shows the printable characters with the ASCII.

48
So, if you received the following
message, what does it mean?

71 111 111 100 32 68 97 121 33

49
So, if you received the following
message, what does it mean?

71 111 111 100 32 68 97 121 33

G o o d D a y !

50
How is the following message sent?

65

51
How is the following message sent?

6 5
54 53
110110 110101
52
Other characters, like letters
with accent marks, and emoji,
are part of a standard called
Unicode that use more bits
than ASCII to accommodate
all these characters.

53
Unicode
Unicode – Egyptian Hieroglyphs

Examples:

Unicode currently defines 154 separate


scripts, including 91 modern scripts
and 63 ancient or historic scripts.

54
Unicode – Arabic
Unicode

When we receive an emoji, our computer is just receiving a


decimal number that it then maps to the image of the emoji.

Face with tears of joy

E.g., Unicode: 128514 .. 11111011000000010 in binary.

55
- Pixels, & the RGB System
- Image, Video, and Audio Files
An image, too, is comprised of many smaller square dots,
or pixels, each of which can be represented in binary with a
system called RGB:

.. with values for red, green, and blue light in each pixel.
By mixing different amounts of each color, we can
represent millions of colors. 57
We can see this in an emoji if we zoom in far
enough:

58
Pixels; Picture Elements

59
What does the following numbers
mean in the context of images
(pixels)?

72 73 33

60
What does the following numbers
mean in the context of images
(pixels)?

RGB: 72 73 33

61
The red, green, and blue values are
combined to get a light-yellow color:

RGB: 72 73 33 

N.B., Computer programs know, based on the context


of its code, whether the binary numbers should be
interpreted as numbers, or letters, or pixels.

62
An RGB Example ..

63
Videos are just many, many images
displayed one after another, at some
number of frames per second.

(Move back & forth quickly between the


next 2 sides .. What did you notice?)

64
65
66
67
68
Sub-fields of CS dealing
with images?
Computer vision; deals with how
computers can gain high-level
understanding from digital images
or videos. It seeks to understand
and automate tasks that the
human visual system can do.

Digital Image Processing; is the


use of a digital computer to
process digital images through
algorithms.

Computer Graphics; studies


methods for digitally creating and
69
manipulating visual content.
What about Audio
(Sound)?

A microphone converts sound waves into voltage changes. If a microphone


is plugged into a sound card, then the voltage can be sampled at regular
intervals (the sample rate) and each value converted into a binary number,
and the series of binary numbers can be stored as a sound file.
Digital Signal Processing (DSP); is the use of digital processing, such as by
computer, to perform a wide variety of signal processing operations.
Exercises
What have we learned?

 What is the difference between ASCII code & Unicode?


 Convert the following ASCII numbers to text:
072 105 033 032 073 032 108 111 118 101 032 067 083 033
 Discuss how images are represented in a computer
system, and the relationship between videos and
images.
 What are the differences between computer graphics,
computer vision, and image processing?
 Watch the first additional resource (video), then define
what is an image resolution?
Up Next ..
Additional Lecture 2
Resources
 Images, Pixels and RGB (in English):
https://www.youtube.com/watch?v=15aqFQQVBWU

 Understanding ASCII and Unicode - GCSE (in English):


https://www.youtube.com/watch?v=5aJKKgSEUnY

 Representing Sound (GCSE) (in English):


https://www.youtube.com/watch?v=1ZV_TxtLd_c

Thank you!

You might also like