You are on page 1of 43

Overview

CSE101: Introduction to Computer Science

01/13
• A device that takes data from the user or other devices
• Computes or manipulates the data by following a set of instructions
called programs
• Provides output to the user.

01/13
2
What is Computer Science (CS)
• Computer science is the study of processes that interact with data
and that can be represented as data in the form of programs.
• Branches of CS:
✔ Software engineering ✔ Human-computer interaction
✔ Graphics and visual computing ✔ Information management
✔ Networking and communication ✔ Intelligent systems
✔ Algorithms and complexity ✔ Operating systems
✔ Architecture and organization ✔ Parallel and distributed computing
✔ Computational science ✔ Platform-based development
✔ Programming languages ✔ Security and information assurance
And so on... 01/13
3
Why is CS Important
• Computers are used in almost every aspect of our lives:
✔ Agriculture
✔ Health Care
✔ Industry Automation
✔ Global Telecommunication
✔ Security and Law
✔ Finance and Banking
✔ Information and Resource Management System
✔ Self-driving Vehicles and Virtual Reality
And so on...
• As computers are less prone to mistakes, they will start to replace humans
• The demand of CS will keep increasing
01/13
4
History of CS
Beginning of Computing:

• Abacus

• 2500 BCE

01/13
5
History of CS
• Charles Babbage

Analytical Engine

• Ada Lovelace

01/13
6
History of CS
Alan Turing:

• Turing Machine (1936)


• Decipher Enigma Code
• Turing Test
• Artificial Intelligence
• Father of Computer Science

01/13
7
Generations
• 1940 – 1956: First Generation – Vacuum Tubes

• 1956 – 1963: Second Generation – Transistors

• 1964 – 1971: Third Generation – Integrated Circuits

• 1972 – 2010: Fourth Generation – Microprocessors

• 2010 – Present: Fifth Generation – Artificial Intelligence


01/13
8
Generations
• 1940 – 1956: First Generation – Vacuum Tubes

01/13
9
Generations
• 1956 – 1963: Second Generation – Transistors

01/13
10
Generations
• 1964 – 1971: Third Generation – Integrated Circuits

01/13
11
Generations
• 1972 – 2010: Fourth Generation – Microprocessors

01/13
12
Generations
• 2010 – Present: Fifth Generation – Artificial Intelligence

01/13
13
How A Computer Works

Inputs Processing Output

Fig. Simple workflow diagram of a computer

✔ Input unit takes data or information from the user and stores into the memory in
the form of digital data

✔ The processing unit performs the processes as per the instructions or


program given to the computer

✔ The output unit provides the results to the user


01/13
14
How A Computer Works
Basic architecture of a computer

Fig. Basic architecture of a computer 01/13


15
How A Computer Works

Functions of the elements/parts of a computer


Input Unit:
The input unit (e.g., keyboard, mouse) takes inputs from the users and stores them into the memory in the form of
digital data.
Memory Unit:
The memory unit is the storage area where all the inputs are stored before processing and the outputs are stored after
processing of inputs.

Central Processing Unit (CPU):


The central processing unit is the workhouse of a computer system; it is the component that executes a program by
performing arithmetic and logical operations on data.

Output Unit:
The output unit (e.g., monitor, printer) provides the results of computer process to the users.
01/13
16
How A Computer Works
Examples: 1) Addition of two numbers [arithmetic operation]
2) Identification of the greater number from two numbers [Logical operation]

Inputs: x = 2 Processing: Output:


Arithmetic
y=4 z = x+y = 2+4 = 6 6

Processing:
Inputs: x = 2 (if x>y) Output:
Logical ‘x is greater’ 4 is greater
y=4
else ‘y is greater’

01/13
17
How A Computer Works
Data representation of a computer
✔ Binary (0, 1) data that deals with computer ✔Real-world data

01/13
18
How A Computer Works
Data representation of a computer
✔ Real-life example

Input Device (Keyboard)


Output Device (Monitor)

HI

1001000 1001001

01001000 01001001 01/13


19
How A Computer Works
Data representation of a computer
• ASCII Code- American Standard Code for Information Interchange

1001000
1001001

01/13
20
How A Computer Works
Different Types of Data Used in Computers
✔ Text- char., num., sym.
✔ Image – 2D/3D matrix of pixels
✔ Video - motion pictures
✔ Audio - voice/sound wave
✔ Graphic – computer generated: graphs, pdf, animation, 3D model, 3D game
▪ Text data representation
Hex. Binary Hex. Binary
ASCII Code 0 0000 8 1000
1 0001 9 1001
Binary 2 0010 A 1010
H - 01001000 3 0011 B 1011
……………………. 4 0100 C 1100
I - 01001001 5 0101 D 1101
……………………. 6 0110 E 1110
01/13 7 0111 F 1111
21
How A Computer Works
Image Data representation
▪ Black-white(binary) image representation ▪ Colour image representation
RGB (255,0,0) (0,255,0) (0,0,255)
Black (0) White (1)

▪ Grayscale (0-255) image representation Dec. Binary


(255) (254) (253) (252) ………… (2) (1) (0) 0 - 00000000
……. 1 - 00000001

…………………
…..
01/13
……………….....
... 22
How A Computer Works
Data representation of a computer
▪ Graphic data representation
▪ Video data representation Graphs
3D model
o Dynamic motion of images at a rate of 30 fps ~
o Data rate of HD video: (1920 × 1080) × (1 × 8) × 30
• number of pixels (i.e., resolution) • bits/pixel
• fps (i.e., number of frames per second)

▪ Audio data representation


3D game

Transducer

Delta modulation 01/13


23
Basic Components of a Computing System

01/13
24
Hardware
Internal Hardware: An Internal Hardware
means hardware that surrounded by the
computer’s casing (e.g. Processor, RAM,
Hard disc, etc.).

External Hardware: By external


hardware, we mean all the computer
device that we can see from outside (e.g.
Keyboard, Mouse, Monitor, Speaker,
etc.).

01/13
25
Software
Software is a set of instructions that tells the computer how
to do certain tasks. A set of instructions is often called a
program.
The two most common types of programs are:
• System software
• Application software

What is System Software?

System Software refers to the operating system and all utility


programs that manage computer resources at a low level.
Systems software includes compilers, loaders, linkers, and
debuggers.

What is Application Software?

Applications software comprises programs designed for an


end user, such as word processors, database systems, and
spreadsheet programs. 01/13
26
Software
Software Hierarchy

01/13
27
Software
The Components of System Software

Operating system - the principal component of system software


Device drivers - help the computer control peripheral devices (i.e., I/O devices)
Utility programs - support, enhance, or expand existing programs
OS shell- The operating system shell includes the user interface (UI). Users only interact with the
OS through the UI. The UI can be –
o Command/character-based (e.g., DOS or UNIX)
o Graphical user interface (GUI), involving windows, menus, icons, etc.

Kernel - program which remains in main memory while the computer is running, and directs other
“nonresident” programs to perform tasks that support application programs

01/13
28
Software
The Components of System Software
What Is an Operating System?
The operating system: A collection of programs that help you use the computer.
o Acts as a smart assistant that moves controls the flow of information to various
components and other programs.
o Manages the usage, storage, and access of programs, data, and processes.

Where is the OS Stored?


The operating system reside in secondary storage.
o ROM is “non-volatile” memory that contains the skeleton operating system, along with
information about where the OS is stored on the Hard disk or other external storage.
o The skeleton operating system allows use of keyboard and both floppy and hard disk
drives.
01/13
29
Software
The Components of System Software

o RAM (Random Access Memory)- The main part of the operating system is
transferred from a secondary storage (e.g., hard disk) to RAM when the computer is
first turned-on.
o This is called the “booting process” or “boot-up”.
o After the boot-up, a portion of RAM is taken up by the OS and other system software,
while other portions are available for loading application software or data.

01/13
30
Software
The Components of System Software

Main Operating System Functions


o Task management- preparing, scheduling, and monitoring of tasks for continuous
processing by the CPU.
o Memory management- allocation of memory for various tasks; transfer of data and
programs from external storage to memory and back; virtual memory management;
cache management.
o Device management- on trolling flow of data to and from input/output devices, and
management of device drivers.
o File and data management- controlling how files are created, accessed, organized,
copied, and modified; controlling and managing the storage of data in external storage
devices.
o System monitoring- monitoring of system resources and devices; error detection and
recovery. 01/13
31
Software
The Components of System Software
Some Terminology
o Process: A process is an instance of a program running in a computer. In Unix and some other
operating systems, a process is started when a program is initiated. A process is a running program
with which a particular set of data is associated so that the process can be kept track of.
o Task: A task is a basic unit of processing that an operating system controls. A process may be a
single task or may involve multiple tasks that are performed together or consecutively.
Task Management Concepts
Multi-tasking: Running more than one task (or process) simultaneously.
o Each process “stealing” or sharing CPU time. • Such as playing a game while a large document is
being printed.
o Each process is allocated a CPU time slice; at the end of the time slice the process in “interrupted”
and its “state” is saved until the CPU can come back to the process; CPU is then allocated to the next
process on the queue.
o Context Switching: Switching from one process or one user to another. Such as from a word
processor to a spreadsheet and back again (both reside in RAM).
o Multi-tasking CPU Time shared between process A and process B. 01/13
32
Software
The Components of System Software
Utility Programs
o Backup utility- program which makes a duplicate copy of the information on your hard disk
o Data recovery utility- program which restores data that has been physically damaged or
corrupted.
o Antivirus software- program that scans hard disks, floppy disks, and memory to detect
viruses.
o Data compression utility- program which removes redundant elements, gaps, and
unnecessary data from a computer’s storage space so that less space (fewer bits) is
required to store or transmit data.
o Disk clean-up utilities- Detect & remove unnecessary files. Detect & correct disk
problems.
o Fragmentation - the scattering of portions of files about the disk in nonadjacent areas, thus
greatly slowing access to the files.
o Defragmenter utility - program that finds all the scattered files on your hard disk and
reorganizes them as contiguous files. 01/13
33
Software
The Components of System Software
Development Software
Computers can only understand instructions that are in machine language
o Machine language instructions are binary encoded operations that make up a
program.
o Programmers, however write programs in a high-level language, not in binary.
o A special program, called a “translator” needs to be used to convert the high-level
language source code into binary machine code that the computer understands. The
machine code program is called the “object” program.
o Two types of translators:
Compilers- translate the whole source code into machine code in one step. After the
translation, the machine code can be executed as a single program. Compiling
language : Java, C++ etc
Interpreters- translate and execute the source code one statement at a time. The
processing is done interactively. Interpreting Language: python,
01/GO,
13
R etc.
34
Program Design and Algorithms
Computer programs are written to solve
problems based on Algorithms.

What is an algorithm?
An algorithm is a sequence of finite
instructions, often used for calculation and
data processing

An algorithm can be represented by pseudocodes or flowcharts


01/13
35
Pseudocode
Pseudocode is a generic way of describing an algorithm. It helps
programmers to plan an algorithm. This is not an actual programming
language, but borrows syntax from popular programming languages.

Pseudocodes can be divided into two types:

1. Sequential Pseudocodes
2. Non-sequential Pseudocodes

01/13
36
Sequential Pseudocode
Sequential pseudocode consists of sequence of program
statements, executed one after another.
Problem 1: Determine the sum of 2 integers.
Pseudocode:
1. Input an integer A
2. Input another integer B
3. Calculate the sum: C=A+B
4. Output C
01/13
37
Non-sequential Pseudocode
Non-sequential pseudocode consists of number of program statements
which are executed based on some flow control statements.
Problem 2: Determine type of payment based on number of hours
worked by a worker.
Pseudocode: 1. Input Hours Worked
2. if Hours Worked > 40 then
3. Output: “Overtime Pay”;
4. else
5. Output: “Regular Pay”;
6. end 01/13
38
Flowchart
Flowchart is a graphical way of writing algorithms for solving problems.
• Rectangle is used for calculations
• Parallelogram is used for input and output
• Oval is used as terminator
• Diamond is used as decision
• Symbols are connected by arrows to represent the order of the
operations

01/13
39
Flowchart Start

For the same problem seen previously: Input A

Input B
Problem 1: Determine the sum of 2 integers.

C = A+B

Output C

End
01/13
40
Flowchart Start

For the same problem seen previously: Input Hours


Worked

yes
Problem 2: Determine type of payment Hours no
Worked > 40
based on number of hours worked by a
worker.
Output Output “Regular
“Overtime Pay” Pay”

End
01/13
41
Programming Languages

• C/C++/C#
• Java • HTML • SQL
• PHP • MySQL
• Python • JavaScript
•R

01/13
42
Summary
• What is computer
• What is computer science (CS)
• Why is CS important
• History of CS
• Generations
• How a computer works
• Basic architecture of a Computer
• Basic Components of a Computing System (Hardware, Software, Data, User)
• How a computer processes data (Binary, ASCII, Unicode)
• Program Designs and Algorithms (Pseudocode, Flowchart)
01/13
43

You might also like