0% found this document useful (0 votes)
3 views

Lecture 1

The document is an introduction to Computer Science (CS500), covering topics such as computer architecture, data representation, algorithms, and the distinction between hardware and software. It explains the fundamentals of computer science, including problem-solving through computations and the role of algorithms and data representation in modern computers. Additionally, it discusses various computer categories, memory types, and numbering systems, providing examples and exercises for better understanding.

Uploaded by

tr.ahmedh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lecture 1

The document is an introduction to Computer Science (CS500), covering topics such as computer architecture, data representation, algorithms, and the distinction between hardware and software. It explains the fundamentals of computer science, including problem-solving through computations and the role of algorithms and data representation in modern computers. Additionally, it discusses various computer categories, memory types, and numbering systems, providing examples and exercises for better understanding.

Uploaded by

tr.ahmedh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

Introduction to Computer Science

(CS500)

Lecture 1
References

• “ Introduction to Computer Sciences”, Lecture Notes, by


Prof. Hesham A. Hefny.

• Lecture Notes by Dr. Ahmed Hamza


Course Outline

• Modern Computer Architecture

• Data Representation In Modern Computers

• Numbering Systems

• Computer Hardware

• Data Manipulation

• Computer Software
What is Computer Science
What is meant by Computer Science
• It is solving problems using computations

• In order to solve a problem computationally, we need:


1. A representation captures all the relevant aspects of the problem
2. An algorithm solves the problem by use of this representation

• A representation that leaves out details of what is being represented is a form of


abstraction

• Example: The farmer, cabbage, goat and wolf problem


þ鐷: , , ,
Start State:
3þ鐷:

þ鐷:
Goal State:
3þ鐷: , , ,
Algorithm
• Algorithm is a finite set of ordered, unambiguous and executable instructions that
terminates with a desired output(s) for given input(s) in a finite amount of time

Example: Farmer, Cabbage, Goat, Wolf problem


Algorithm ...

Example: find the average of two numbers


Solution Algorithm
1. Read the two number (inputs)
2. Sum the two numbers
3. Divide the sum by 2
4. Store the division quotient
5. Display the stored quotient (output)
What is Computer
What is Computer

• A machine that can be instructed to carry out sequences of arithmetic


or logical operations automatically via computer programming.

• It receives input, stores and manipulates data, and provides output in a


useful format

• It includes hardware and software


Computer Hardware

• The computer physical components


Computer Software
• Programs executed on the computer

• Computer software can be:


» system software
Operating systems
» applicatoin software

» It can be
» Desktop application
Office package, calculator, games
» Mobile application
Android
» Web application
Mail application, websites
Hardware Versus Software

12
Computer Categories

• Modern computers can be categorized respecting:

– Usage
• Special-purpose computers
• Geneeral-purpose computers

– Size and computations


• Supercomputer
• Microcomputer
Computer Categories: Size and computaional capabilities

Super computer

• the highest in speed, the most expensive

• used to process massive amounts of data.

• used in defense and military applications, wheather forecasting, complex


scientific applications
Computer Categories: Size and computaional capabilities

Microcomputers
• CPU is manufactored as a single chip called microprocessor
• less powerful and cost
• can be categorized into:
– Desktop
–used for a variety of user applications (e.g., email, web browsing, document processing)

 Portable
categorized into:
•Notebook (or laptop)

•Tablet
Architecture of Modern Computer
Central Processing Unit (CPU)
Central Processing Unit (CPU):
the main unit of the computer
responsible for executing programs stored in the internal memory.
It consists of two parts:
1) Arithmetic and Logic Unit (ALU) .
2) Control Unit (CU) .
1) Arithmetic and Logic Unit (ALU): performs:
• Arithmetic operations: Addition, Subtraction, Multiplication, Division, Modulus, Power,… etc.
• Logical: AND, OR, XOR, SHIFT, ROTATE,…etc.
2) Control Unit (CU):
responsible for controling all the CPU operations, such as:
• Decoding the instructions of programs stored in the internal memory.
• Controlling the flow of information through the ALU, I/O, and internal memory.
Internal Memory
Internal Memory:

Composed of chips of integrated circuits which are capable of quickly storing and retrieving data. It can be:

1) Read Only Memory (ROM).

2) Random Access Memory (RAM).

3) Cache Memory

1) Read Only Memory (ROM):

• It contains built-in programs (e.g., BIOS) that are needed by the computer to start operation
(booting up) when powered on.

• Theses programs are stored permanently during the manufacturing and can’t be lost when power
is turned off (nonvolatile memory)

• The CPU can only read from the ROM.


Internal Memory
1) Read Only Memory (ROM):

• It contains built-in programs (e.g., BIOS) that are needed by the computer to start operation (booting up) when
powered on.

• Theses programs are stored permanently during the manufacturing and can’t be lost when power is turned off
(nonvolatile memory)

• The CPU can only read from the ROM.

2) Random Access Memory (RAM):

• It’s the main memory of the computer.

• It stores the programs and their data which are needed to be executed by the CPU.

• The CPU can read from and write to RAM .

• When the power is off, all the stored data in RAM are lost (volatile memory).

• When you buy a computer, you pay for RAM not ROM.

3) Cache Memory:

• Very high-speed memory acts as temporary area (volatile memory) between the CPU and RAM.

• store program instructions and data that are frequently re-referenced by the program during operation.
External Storage
External Storage (Auxiliary Memory):

• It’s a secondary memory (nonvolatile storage).

• It holds the programs and data permanently even if the power is off.

• It has many forms such as Compact Disks (CDs), Digital Versatile Disks (DVDs), and Flash Memories.

Input Devices:

• Devices that allow a user to enter data to a computer,

• Examples of these devices such as keyboard, mouse, light-pen, scanner, microphone and …etc.

Output Devices:

Examples of these devices are screen, speaker, printer, and …etc.


Data Representation In Modern Computer

Multimedia
Data Coding & Decoding
• Human senses deal with a variety of data.

• Input devices of computer translates these data into electrical signals.

• Electrical signals are then translated into universal format (0s,1s), this is known as
coding.

• After processing, output devices transform back data into their original form, this is
known as decoding.
Text Representation:
Extended ASCII
Image Representation
• Images can be represented as a collection of dots (pixels). Such pixels are arranged in rows and
columns over the image.

• Image resolution depends on the number of pixels in the image and the higher the resolution the
more information the image contains

• In the case of a simple black and white image, each pixel can be represented by a single bit whose
value depends on whether the corresponding pixel is black or white.
Audio Representation
• Audio is sound and the sound signal is analog signal.

• The representation of audio signal requires converting it from analog signal into digital signal
(digitization) by the sampling and quantization processes.

• Videos can be encoded as series of image frames with synchronized audio tracks also encoded
using bits.
Data representation in Computers

• All information entered to the modern digital computers,


(regardless of being numbers, characters, symbols, colors,…),
should be represented as a sequence of binary digits.

• A bit has one of two values (0 or 1)


Numbering system
• To define any numbering system, we have to determine:
• its base (radix)
• list of adopted symbols

Number Base/Radix Symbols Example


System
Decimal 10 0,1,2,3,4,5,6,7,8,9 (3)10, (542)10, (60.58)10

Binary 2 0,1 (0)2, (011)2, (10101.010)2


Ternary 3 0,1,2 (0)3, (021)3, (001.021)3
Octal 8 0,1,2,3,4,5,6,7 (3)8, (542)8, (60.57)8
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F (AD)16, (542)16, (60.5A8)16
Numbering System Conversion
From any numbering system (R) to decimal numbering system (10)

( ...... . ...... ) =
* + * + ....... + *
+
* + * + ....... + *
Example
Example: From binary to decimal
• The equivalent decimal value for the binary number:
(11011.101)2 =
1*2 +1*2 + 0*2 + 1*2 + 1*2 + 1*2 + 0*2 + 1*2
= (27.625)

• Another solution:

1 1 0 1 1 . 1 . 0 . 1 .
= 1*16 +1*8 +0*4 +1*2 +1*1 +1*0.5 +0*0.25 +1.0.125
= (27.625)10
Excercise

Find the decimal equivalent for the following numbers:


• (201.3)3
• (127.64)8
• (1CF.A3)16
From Decimal Numbering system to others
(502569)10 is equivalent to (???)r
Integer part Remainder

r÷ 502569

(0.365)10 is equivalent to (???)r

Fraction part Integer

r* 0.365
Example: From Decimal to Binary (Integer part)

Convert (41)10 to its equivalent binary value

i.e., (41)10= (??)2

2 ÷
Example: From Decimal to Ternary

• Convert (41)10 to its equivalent Ternary value


Integer part Reminder part

• i.e., (41)10= (??)3 3÷ 41


13 2
4 1
1 1
0 1

(1112)3
Exercise

• Convert (41)10 to its equivalent octal and Hexadecimal


values

• i.e., (41)10= (??)8


• (41)10 =(??)16
From Decimal To Binary(Fraction Part)
Convert (0.6875)10 to the binary system.
Example: From Decimal to Binary

Convert (0.625)10 to its equivalent binary value

i.e., (0.625)10= (??)2 Fraction part Integer part

2* 0.625
0.25 1
0.5 0
0 1

(0.101)2

Therefore, the number (0.1011)2 is the exact binary equivalent to the decimal number (0.625)10
Example: From Decimal to Ternary

Convert (0.012345679)10 to its equivalent Ternary value

i.e., (0.012345679)10= (??)3 Fraction part Integer part

3* 0.012345679
0.0370370375 0
0.111111111 1
0.3333333 0
0.9999999 1

(0.0101)3

Therefore, the number (0.0101)2 is the ternary equivalent to the decimal number (0.012345679)10
Excercise

Convert the following:

• (0.390625)10 = ( ?? )8

• (0.25)10 = ( ?? )16
From Decimal to binary
• Convert (174.390625)10 to its binary value

Therefore, the number (10101110.011001)2 is the exact binary equivalent to the decimal number (174.390625)10
From decimal to ternary
• Convert the decimal number (124.33) 10 to its equivalent ternary
number

Therefore, the number (11121.02222)3 is the approximate ternary equivalent to the decimal number (124.33)10
From Decimal to Octal
• Convert the decimal number (167.390625)10 to its equivalent octal number.

Therefore, the number (247.31)8 is the exact octal equivalent to the decimal number (167.390625)10
From decimal10 to hexadecimal16

• Convert the decimal (247.390625)10 to its equivalent hexadecimal number.

Therefore, the number (F7.64)2 is the exact hexadecimal equivalent to the decimal number (247.390625)10
Exercise

Convert the following:

• (95.236)10= (??)8

• (153.513)10 = (??)8
From Binary to Octal and Octal to Binary
• There are two methods:
First (Indirect Conversion):

Second (Direct Conversion):


Each 3-binary digits are replaced by one octal digit , and vice versa , using the following table:
Octal 0 1 2 3 4 5 6 7
Binary 000 001 010 011 100 101 110 111
Indirect Method: Example

(1001101.1011)2 = (??)8
Solution
• Step 1:
convert (1001101.1011)2 to (??)10
Indirect Method: Example...
Step2:
Convert from (77.6875)10 = (??)8
From Binary to Octal and Octal to Binary
• There are two methods:
First (Indirect Conversion):

Second (Direct Conversion):


Each 3-binary digits are replaced by one octal digit , and vice versa , using the following table:

Octal 0 1 2 3 4 5 6 7
Binary 000 001 010 011 100 101 110 111
Direct Method: Example

Using the direct method, convert the binary number


(1001101.1011)2 to octal
Another Example
find the octal equivalent of (10110001101011.111100000110)2
Binary to Hexadecimal and Hexadecimal to Binary

There are two Methods:


First (Indirect conversion):

• Second(Direct conversion):
Each 4-binary digits are replaced by one hexadecimal digit , and
vice versa , using the following table:

Hexa 0 1 2 3 4 5 6 7 8 9 A B C D E F
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Direct conversion Example

Convert the hexadecimal (3BC. 2E)16 directly to its equivalent


binary number.
Direct Conversion Example
Convert the following:
(110101.101)2 = (???)16

Solution

(0011 0101. 1010)2


(3 5. A)16

Convert the following:


(111010.11011)2 = (???)16
Solution
Direct Conversion Example
Convert the following:
(10110001101011.1110010)2 = (???)16
Solution

Convert the following:


(DEF.A1)16 = (???)2
Solution

(D E F.A 1)16
(1101 1110 1111. 1010 0001)2
Hexa-Octal Conversion

There are two methods:


• First Method
1- convert hexa to binary
2- convert binary to Octal

• Second Method
1- convert hexa to decimal
2- convert decimal to octal
Hexa to octal conversion Example

• (2F.C4)16= (???)8
Octal-Hexa Conversion

there are two methods:


• First Method
1- convert octal to binary
2- convert binary to hexa

• Second Method
1- convert Octal to decimal
2- convert decimal to hexa
Hexa to octal conversion Example

• (762.013)8= (???)16

Solution

You might also like