CSC 101 Note

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

CSC 101 LECTURE NOTE

Introduction to Computer Science

B.SC.
ICEEL IBBUL
Chapter One
1.0 Brief History of Computer

Computers truly came into their own as great inventions in the last two decades
of the 20th century. But their history stretches back more than 2500 years to the
abacus: a simple calculator made from beads and wires, which is still used in
some parts of the world (e.g. China) today. The difference between an ancient
abacus and a modern computer seems vast, but the principle of making repeated
calculations quicker than the human brain is exactly the same.

1.0.1 Cogs and Calculators

It is a measure of the brilliance of the abacus, invented in the Middle East


circa 500 BC, that it remained the fastest form of calculator until the middle
of the 17th century. Then, in 1642, aged only 18, French scientist and
philosopher Blaise Pascal (1623–1666) invented the first practical
mechanical calculator, the Pascaline, to help his tax-collector father do his
sums. The machine had a series of interlocking cogs (gear wheels with teeth
around their outer edges) that could add and subtract decimal numbers.
Several decades later, in 1671, German mathematician and
philosopher Gottfried Wilhelm Leibniz (1646–1716) came up with a
similar but more advanced machine. Instead of using cogs, it had a "stepped
drum" (a cylinder with teeth of increasing length around its edge), an
innovation that survived in mechanical calculators for 300 hundred years. The
Leibniz machine could do much more than Pascal's: as well as adding and
subtracting, it could multiply, divide, and work out square roots. Another
pioneering feature was the first memory store or "register."

Apart from developing one of the world's earliest mechanical calculators,


Leibniz is remembered for another important contribution to computing: he
was the man who invented binary code, a way of representing any decimal
number using only the two digits zero and one. Although Leibniz made no
use of binary in his own calculator, it sets others thinking. In 1854, a little
over a century after Leibniz had died, Englishman George Boole (1815–
1864) used the idea to invent a new branch of mathematics called Boolean
algebra. In modern computers, binary code and Boolean algebra allow
computers to make simple decisions by comparing long strings of zeros and

1
ones. But, in the 19th century, these ideas were still far ahead of their time. It
would take another 50–100 years for mathematicians and computer scientists
to figure out how to use them.

1.0.2 Engines and Calculators

Neither the abacus, nor the mechanical calculators constructed by Pascal and
Leibniz really qualified as computers. A calculator is a device that makes it
quicker and easier for people to do sums—but it needs a human operator. A
computer, on the other hand, is a machine that can operate automatically,
without any human help, by following a series of stored instructions called a
program (a kind of mathematical recipe). Calculators evolved into computers
when people devised ways of making entirely automatic, programmable
calculators.

The first person to attempt this was a rather obsessive, notoriously grumpy
English mathematician named Charles Babbage (1791–1871). Many regard
Babbage as the "father of the computer" because his machines had an input
(a way of feeding in numbers), a memory (something to store these numbers
while complex calculations were taking place), a processor (the number-
cruncher that carried out the calculations), and an output (a printing
mechanism) the same basic components shared by all modern computers.
During his lifetime, Babbage never completed a single one of the hugely
ambitious machines that he tried to build. That was no surprise. Each of his
programmable "engines" was designed to use tens of thousands of precision-
made gears. It was like a pocket watch scaled up to the size of a steam engine,
a Pascal or Leibniz machine magnified a thousand-fold in dimensions,
ambition, and complexity. For a time, the British government financed
Babbage to the tune of £17,000, then an enormous sum. But when Babbage
pressed the government for more money to build an even more advanced
machine, they lost patience and pulled out. Babbage was more fortunate in
receiving help from Augusta Ada Byron (1815–1852), Countess of
Lovelace, daughter of the poet Lord Byron. An enthusiastic mathematician,
she helped to refine Babbage's ideas for making his machine programmable
and this is why she is still, sometimes, referred to as the world's first computer
programmer. Little of Babbage's work survived after his death. But when, by
chance, his notebooks were rediscovered in the 1930s, computer scientists
finally appreciated the brilliance of his ideas. Unfortunately, by then, most of
these ideas had already been reinvented by others.

2
Babbage had intended that his machine would take the drudgery out of
repetitive calculations. Originally, he imagined it would be used by the army
to compile the tables that helped their gunners to fire cannons more
accurately. Toward the end of the 19th century, other inventors were more
successful in their effort to construct "engines" of calculation. American
statistician Herman Hollerith (1860–1929) built one of the world's first
practical calculating machines, which he called a tabulator, to help compile
census data. Then, as now, a census was taken each decade but, by the 1880s,
the population of the United States had grown so much through immigration
that a full-scale analysis of the data by hand was taking seven and a half years.
The statisticians soon figured out that, if trends continued, they would run out
of time to compile one census before the next one felt due. Fortunately,
Hollerith's tabulator was an amazing success: it tallied the entire census in
only six weeks and completed the full analysis in just two and a half years.
Soon afterward, Hollerith realized his machine had other applications, so he
set up the Tabulating Machine Company in 1896 to manufacture it
commercially. A few years later, it changed its name to the Computing-
Tabulating-Recording (C-T-R) company and then, in 1924, acquired its
present name: International Business Machines (IBM).

1.1 Generation of Computer

A generation refers to the state of improvement in the development of a product.


This term is also used in the different advancements of computer technology.
Generations of computers has been divided into five, according to the
development of technologies used to fabricate the processors, memories and I/O
units. With each new generation, the circuitry has gotten smaller and more
advanced than the previous generation before it. As a result, speed, power, and
memory of computers have proportionally increased. New discoveries are
constantly being developed that affect the way we live, work and play.

1.1.1 First Generation Computers


The period of first generation was from 1946-1959. During this generation,
these devices used electronic switches, in the form of vacuum tubes. These
electronic tubes were made of glass and were about the size of a light bulb. The
first-generation computers were huge, slow, expensive, and often undependable.
It Consume more power with limited performance.

Vacuum tube (as the major component) was an extremely important step in the
advancement of computers. Its purpose was to act like an amplifier and a switch.
Without any moving parts, vacuum tubes could take very weak signals and make

3
the signal stronger (amplify it). Vacuum tubes could also stop and start the flow
of electricity instantly (switch).

Fig 1.1: First Generation Computer

1.1.1.1 Characteristics of first-Generation Computers


• Uses Vacuum tubes for circuitry
• Uses Magnetic tape / Magnetic drums for memory
• Relied on machine language, the lowest level programming
language
• Input was based on punch cards and paper tape
• Output was displayed and printouts
• Mainly used for scientific computations.

1.1.1.2 Kinds of First-Generation Computers


• ENIAC - Electronic Numerical Integrator and Calculator
• EDSAC – Electronic Delay Storage Automatic Calculator
• EDVAC – Electronic Discrete Variable Automatic Computer
• UNIVAC – Universal Automatic Computer

4
1.1.2 Second Generation Computers

The period of second generation was from 1959-1965. Second generation


witnessed several important developments at all levels of computer system
design, ranging from the technology used to build the basic circuits to the
programming languages used to write scientific applications. This generation
begins with the first computers built with transistors; small devices that transfer
electronic signals across a resistor. Because transistors are much smaller, use
less power, and create less heat than vacuum tubes, the new computers were
faster, smaller, and more reliable than the first-generation machines were.
Transistors were used in place of vacuum tubes. This was faster, more reliable,
smaller, and much cheaper to build than a vacuum tube. One transistor
replaced the equivalent of 40 vacuum tubes. These transistors were made of
silicon, an abundant element found in beach sand and glass. Therefore, they
were very cheap to produce. Transistors were found to conduct electricity faster
and better than vacuum tubes. They were also much smaller and gave off
virtually no heat compared to vacuum tubes.

Fig. 1.2: Second Generation Computer

1.1.2.1 Characteristics of Second-Generation Computers


• Uses Magnetic tape / Magnetic disk as secondary memory
• Input was based on punch cards and paper tape
• Moved from Machine Language to Assembly language

5
• Output was displayed and printouts
• HLL such as FORTRAN, COBOL were used
• Lesser power consumption and better performance.
• Used in business, industry and commercial organizations for
preparation of payroll, inventory control, research, scientific &
engineering analysis and design etc.

1.1.2.2 Kinds of Second-Generation Computers


• IBM 1401, IBM 7090 and 7094
• UNIVAC 1107
• PDP-1 and 8

1.1.3 Third Generation Computers


The period of third generation was from 1965-1971. Technology changes in this
generation include the use of integrated circuits, or ICs (semiconductor
devices with several transistors built into one physical component). An
integrated circuit (IC) is a complete electronic circuit on a small chip made of
silicon. These computers were more reliable and compact than computers made
with transistors, and they cost less to manufacture.

Fig. 1.3: Third Generation Computer

1.1.3.1 Characteristics of Third Generation Computers


• Used IC (Integrated circuit) for circuitry

6
• In the beginning, magnetic core memories were used. Later they were
replaced by semiconductor memories (RAM & ROM)
• Introduced microprogramming
• Used of High-level languages (FORTRAN-II, COBOL, PASCAL
PL/1, BASIC etc).
• Cache and virtual memories were introduced (Cache memory makes
the main memory appear faster than it really is. Virtual memory
makes it appear larger)
• Input was based on keyboard
• Output was based on monitor
• Interfaced with operating system which allow the application to run
multiple device at a time
• Small Scale Integration and Medium Scale Integration technology
were implemented in CPU, I/O processors etc.
• Smaller & better performance
• Comparatively lesser cost
• Faster processors

1.1.3.2 Kinds of Third-Generation Computers


• IBM-360 Series
• Honeywell-6000 series
• PDP (Personal Data Processor)
• IBM-370/168
• TDC-316

1.1.4 Fourth Generation Computers


The period of fourth generation was from 1971-1980. There is much key
advancement that were made during this generation, the most significant of
which was the use of the microprocessor—a specialized chip developed for
computer memory and logic. This revolutionized the computer industry by
making it possible to use a single chip to create a smaller “personal” computer.

7
Fig. 1.4: Fourth Generation Computer

1.1.4.1 Characteristics of Fourth-Generation Computers


• Tens of thousands of transistors can be placed in a single chip (VLSI
design implemented)
• Microprocessor (Thousands of IC built on a single silicon chip) was
introduced as CPU
• Semi-conductor memory chips were used as the main memory
• Secondary memory was composed of hard disks – Floppy disks &
magnetic tapes were used for backup memory
• Introduction of GUI, mouse, handheld devices
• Introduced C/C++ language and Unix OS
• LAN and WANS were developed (where desktop work stations
interconnected)
• Secondary memory was composed of hard disks – Floppy disks &
magnetic tapes were used for backup memory
• Less power consumption
• High performance, lower cost and very compact
• Much increase in the speed of operation

8
1.1.4.2 Kinds of Fourth-Generation Computers
• DEC 10
• STAR 1000
• PDP 11
• CRAY-1 (Super Computer)
• CRAY-X-MP (Super Computer)
1.1.5 Fifth Generation Computers
The period of fifth generation is 1980-till date. In the fifth generation, VLSI
technology became ULSI (Ultra Large-Scale Integration) technology,
resulting in the production of microprocessor chips having ten million
electronic components.
This generation is based on parallel processing hardware and AI (Artificial
Intelligence) software. AI is an emerging branch in computer science, which
interprets the means and method of making computers think like human
beings. All the high-level languages like C/C++, Java, .Net etc., are used in
this generation.

Fig. 1.5: Fifth Generation Computer

9
Chapter Two
2.0 Introduction to Computer

The word “computer” comes from the word “compute” which means to
calculate. A computer is an electronic device which can accept data, store data
in its memory, process them and produce useful information.

Fig. 2.0: Representation of a computer

Data: Facts about a person, object or place, e.g. name, age, complexion,
school, class, height (unprocessed information).

Information: processed data or a meaningful statement e.g. examination


results, net pay of workers. etc.

2.0.1 Characteristics of Computer

a. Speed: Computer can manipulate large amount of data in very little


time.
b. Storage capacity: Computer has both internal and external storage
facilities for holding data and instruction.
c. Accuracy: Its accuracy is very high and its consistency can be relied
upon.
d. Reliability: Computers are immune to tiredness and lack of
concentration. It performs the last job with the same speed and
accuracy as the first every time.
e. Versatility: Computers can perform various types of jobs efficiently.
f. Diligence: Can perform repetitive calculations.
g. Automatic: Once a program is in the memory, it can run each time it
is opened. Little or no instruction is required
h. Flexibility: It can perform any type of task once the task is reduced to
logical steps.
i. They have no feelings
j. Lack of decision-making power
k. No IQ – computers are dumb machines; they need to be told each and
every step.

10
l. Reflects human error

2.1 Computing System

The computing system consists of the computer system, user and the
computing environment. The computer system is made up of hardware and
software.

Fig 2: Diagram of the Computing Environment

2.1.1 Hardware
Hardware: Are the physical components of the computer. Comprise of the input
unit, the central processing unit (ALU, Control unit and Main Memory) and the
output unit. The main memory is made up of RAM (Random Access Memory)
and ROM (Read Only Memory).

2.1.2 Software
These are series of instructions that enable the computer to perform tasks. A
program is made up of set of instructions to perform a task. Software is made up
of series of programs. This can be categorized into three (3):
• System Software
• Utility Software
• Application software
• System Software: This is the program that facilitates the use of
the hardware and provides a suitable environment for writing,
editing, debugging, testing and running of user program. Usually,
every computer system comes with collection of the suits of
programs which are provided by the Hardware Manufacturer. E.g
Operating system (which act as an Interface between the user and
computer hardware).

11
• Utility Software: Also, known as general purpose programs, they
are used for copying files, file conversion, housekeeping
operations etc.
• Application Software: Set of programs designed to solve a
problem of specific nature. It could be a user program or supplied
by the manufacturer.
2.1.3 Computer User
These are different categories of people or personnel that operate the
computer systems. We have expert users and end users.

2.1.4 Computing Environment


This is the building which contains other elements of the computing system
including furniture, uninterrupted power supply (UPS), stabilizer, air
conditioners etc.

2.2 Classification of Computers


Computer can be classified based on the following;
2.2.1 Signal
A signal is an electrical or electromagnetic current that is used for carrying
data from one device or network to another. It is the key component behind
virtually all communication. This can further be sub-divided into the
following:
2.2.1.1 Analog Computer
Analog computers used continuous values. It measures the data it deals
with rather than count. Computations are carried out with physical
quantities such as voltage, current, temperature etc. The main
advantage of Analog computers is that all calculations take place in
parallel and hence these are faster. Accuracy is poor as compared to
digital computers. These are mostly used in engineering and scientific
applications.
2.2.1.2 Digital Computer
The digital computer work upon discrete values (separate, disunited,
discontinuous data). It counts the data it deals with, whether symbols,
numbers or letters. They convert the data into binary digits (0 and 1) on
input to the computer. After processing, the binary digits are converted
back to alphanumeric for output. Digital computers are much faster
than Analog computers and far more accurate and are used for business
and scientific applications.

12
2.2.1.3 Hybrid Computer

Hybrid computers are computers that comprise features of analog


computers and digital computers

2.2.2 Purpose
Computers differ based on their data processing abilities. They are
classified according to purpose, data handling and functionality. These
computers can be specified as;
2.2.2.1 Special Purpose Computer
These computers are Designed to perform a specific task. The
instructions to carry out the task are permanently stored in the machine.
They are not versatile, less complex than the general purpose and very
efficient for the tasks for which they are designed for. E.g.: Computer
used for military purpose, navigational purpose, for tracking airplane
or missiles, etc.
2.2.2.2 General Purpose Computer
Works on different types of program input to it and thus be used in
countless applications. The programs are not permanently stored, more
flexible than special purpose computers, they can handle a wide variety
of problems with Less efficient than the special purpose computers due
to such problems as inadequate storage, low operating etc. More
complex than special purpose computer. These computers are very
versatile. Examples of areas where general purpose computers are
employed include Payroll, Banking, billing etc.

2.2.3 Capacity
Different types of computers can be grouped into four major categories
according to size. Each category excels at specific functions. Generally,
sizes of computers determine the processing abilities. Larger computers
have higher processing speeds while smaller ones offer the better
experience for personal computing.
2.2.3.1 Micro Computer/Personal Computer
These are the smallest, least expensive and the most used types of
computers. They have a small memory, less processing power,
physically small and permit fewer peripherals compared to super and
mainframe computers. The operating system used include Windows,
Mac OS X, Linux, IOS, and Android with categories like Desktop,
Laptops, Mobile and Wearable Computers.

13
2.2.3.2 Mini Computer
Minicomputers are general purpose devices without the monumental
expenses associated with a larger system. Their processing power is
below that of mainframe system but above the capabilities of PC. Eg.
MicroVAX II, Texas Instrument TI-990 and K-202.
2.2.3.3 Main Frame Computer
Also known as big iron, mainframe are large sized computer types.
They are equally powerful but fall short in terms of the computation
ability in supercomputers. They are like big file servers, enabling
multiple users from nearby and remote locations to access resources at
the same time.
They are resilient as they are capable of operating for over ten years
without failing. E.g. System z9, Fujitsu-ICL VME and Hitachi’s Z800.
2.2.3.4 Super Computer
This is the most powerful in terms of speed and accuracy. They are type
of computers used in solving complex mathematical computations.
They are capable of executing trillions of instructions per second,
which is calculated in floating point operations per second (FLOPS).
Eg. Roadrunner (IBM-USA), Jaguar (Cray-USA), Tianhe-1A (NUDT-
China) etc.
2.3 Functional Component of Computer
Computer is a device that operates upon information or data. It is an electronic
device which accepts input data, stores the data, does arithmetic and logic
operation and outputs the information in desired format.

Since computer follows input – process – output cycle, the first stage is
performed in computer by input unit, second stage by its central processing unit

14
and output unit performs the third stage. The main memory holds the input and
intermediate output during processing.

Input unit accepts coded information from human operators through


electromechanical devices such as the keyboard. The information received is
either stored in the memory for later reference or immediately used by the
Arithmetic and Logic circuitry to perform the desired operation. Finally, the
result is sent back to the outside through the output unit.

2.3.1 Input Unit


An input unit of a computer system performs the following functions:
• It accepts (or reads) instructions and data from outside world
• It converts these instructions and data in computer acceptable form
• It supplies the converted instructions and data to the computer system for
further processing.
2.3.1.1 Input Devices
Keyboard, Mouse, Webcam, Compact Disc, Digital Camera, Drawing
Tablet, Microphone, Light pen, Joystick etc.
2.3.2 Memory Unit
The memory unit stores program and data. It has the following attributes;

• To store all the data to be processed and the instructions required


for processing.
• To store inter mediate results for processing.
• To store final results of processing before these results are
released to an output device.
There are two classes of memory devices: - Primary memory and Secondary
memory.

2.3.2.1 Primary Memory / Main Memory


This section of the computer consists of a device used to store
information which will be used during computation. It is used to hold
both intermediate and final results as the computer proceeds through the
program, E.g. ROM and RAM chips.

ROM (Read Only Memory): ROM is non-volatile. This means


the contents do not disappear when the power to the
system is turned off.

Examples of ROM (Read Only Memory):


• PROM: Programmable ROM
• EPROM: Erasable Programmable ROM

15
• EEPROM: Electrically Erasable Programmable
ROM

RAM (Random Access Memory): The memory is read-write,


and volatile. This means the contents disappear when the
power to the system is turned off.

Examples of RAM (Random Access Memory)

• (DRAM) Dynamic RAM


• (SRAM) Static RAM
• SDRAM (Synchronous Dynamic RAM)
• DDRRAM (Double Data Rate Synchronous DRAM)

2.3.2.2 Secondary Storage (Auxiliary)


Because the primary storage capacity of most computers is limited,
expensive and not always possible to hold large volume of data and
instruction in the primary memory, hence it becomes necessary to have
secondary or auxiliary memory for holding data and instructions not
currently in use. E.g. Hard Disk, Compact Disk, magnetic tape, magnetic
disk, floppy diskette, flash drive etc.

2.3.3 Central Processing Unit (CPU)


The heart of the computer system is the Processor unit. It is the central
processor that makes comparisons, performs calculations, reads, interprets
and controls the execution of instructions. It consists of Arithmetic and Logic
Unit and Control Unit.

• Arithmetic and Logic Unit (ALU): Perform mathematical


calculations, compare numeric and non-numeric values
and make decisions.
• Control Unit (CU): Supervises the operation of the entire
computer. It selects the program statement from the
memory, interpret the statement and send appropriate
electronic impulse to ALU and storage unit so that these
units can carry out the operations required. Hence, it acts
as the central nervous system for the component of the
computer

16
2.3.4 Output Unit
An output unit of a computer system performs the following functions:
• It accepts the results produced by the computer, which are in
coded form and hence, cannot be easily understood by us
• It converts these coded results to human acceptable
(readable) form
• It supplies the converted results to outside world

Common output devices include: Visual display unit (Monitor), Speakers,


and Printers.

Types of printers

Impact printers, Dot matrix printers, Daisywheel


printers, Line printers, Chain printers, Drum printers,
Thermal printers, Ink jet printers, Laser printers.

2.4 Computer Languages

Programming Languages: Is a set of Notation in which we express instructions to


the computer.

2.4.1 Categories of Languages

We can choose any language for writing a program according to the need.
However, a computer executes programs only after they are represented in
binary form (Sequences of 1’s and 0’s). Programs written in any other
language must be translated to the binary representation of the instructions
before they can be executed by the computer. Programs written for a
computer may be in one of the following categories of languages.

2.4.1.1 Machine Language (First Generation Language)


This is the sequence of instructions written in the form of binary numbers
consisting of 1’s, 0’s to which the computer responds directly. Machine
language is considered to be the first-generation language.

Advantage:
It is faster in execution since the computer directly starts
executing it.

Disadvantage:
It is difficult to understand and develop a program using
machine language. Anybody going through this program for

17
checking will have a difficult task understanding what will be
achieved when this program is executed.

2.4.1.2 Assembly Language (Second Generation Language)


When we employ symbols (letter, digits or special characters) for the
operation part, the address part and other part of the instruction code, this
representation is called an assembly language program. This is
considered to be the second-generation language.
Machine and assembly languages are referred to as low-level languages
since the coding for a problem is at the individual instruction level. Each
machine has got its own assembly language, which is dependent upon the
internal architecture of the processor.
An assembler is a translator, which takes it input in the form of an
assembly language program and produces machine language code as its
output.

The following program is an example of an assembly language program


for adding two numbers X and Y and storing the result in some memory
location.

LD A, 7 : Load Register A with 7


LD B, 10 : Load Register B with 10
ADD A, B : Add A and B
LD (100), A : Save the result in the location 100
HALT : Halt Process
The usage of mnemonics (like LD, ADD, and HALT) has improved the
readability of our program significantly.

A machine cannot execute an assembly language program directly, as it is


not in a binary form. An assembler is needed in order to translate an
assembly language program into the object code executable by machine.
Advantage:
Writing a program into assembly language is more
convenient than in the machine language. Instead of binary
sequence, as in machine language, it is written in the form of
symbolic instructions.

Disadvantages:
• Assembly language is specific to particular machine
language architecture.

18
• Assembly language program is not as fast as machine
language.
2.4.1.3 High Level Languages (Third Generation Languages)
The main purpose of high-level language is to enable the programmer to
write the program more easily. These languages consist of a set of words
and symbols. The most important characteristic of high-level language is
that it is computer independent. Programming languages like C, COBOL,
FORTRAN and BASIC are called high-level languages.

The Program shown below is written in BASIC to obtain the sum of two
numbers
10 LET X = 7
20 LET Y = 10
30 LET SUM = X + Y
40 PRINT SUM
50 END
Since a high-level language must be translated into a form the machine
can understand, this is done by software called Compiler which takes the
source code as input and produces as the output the machine language code
at the machine on which it is to be executed. During the process of
translation: the compiler reads the source programs statement-wise and
checks the syntactical errors. If there is any error, the computer generates
a printout of the errors it has detected.

Advantages:

These are the main advantages of high-level languages

• Readability: - Program written in these languages are more


readable than assembly and machine language.
• Portability: - Programs could be run on different machines with
little or no change.
• Easy Debugging: - Errors could easily be removed (debugged)
• Easy Software Development: - Software could easily be
developed. Commands of programming language are similar to
natural languages (ENGLISH)
• Easy to Maintain
• Easy to Learn

19
Chapter Three
3.0 Introduction to Problem Solving

Regardless of the area of study, computer science is all about solving problems with
computers. The problems that we want to solve can come from any real-world
problem or perhaps even from the abstract world. We need to have a standard
systematic approach to solving problems.
3.1 Problem Solving

Is the sequential process of analyzing information related to a given situation and


generating appropriate response options?
There are six (6) steps that you should follow in order to solve a problem:

• Understand the Problem


It sounds strange, but the first step to solving any problem is to make sure that
you understand the problem that you are trying to solve. You need to know:

o What input data/information is available?


o What does it represent?
o What format is it in?
o Is anything missing?
o Do I have everything that I need?
o What output information am I trying to produce?
o What do I want the result to look like … text, a picture, a graph…?
o What am I going to have to compute?

• Formulate a Model
Now we need to understand the processing part of the problem. Many
problems break down into smaller problems that require some kind of simple
mathematical computations in order to process the data.

• Develop an Algorithm
Now that we understand the problem and have formulated a model, it is
time to come up with a precise plan of what we want the computer to do.
An algorithm is a precise sequence of instructions for solving a problem.

Some of the more complex algorithms may be considered “randomized


algorithms” or “non-deterministic algorithms” where the instructions are not

20
necessarily in sequence and in may not even have a finite number of
instructions.

To develop an algorithm, we need to represent the instructions in some way


that is understandable to a person who is trying to figure out the steps
involved. Two commonly used representations for an algorithm is by using;
(a) pseudo code, or
(b) flow charts.

(a) Pseudocode
Pseudocode is a simple and concise sequence of English-like instructions
to solve a problem.

◼ Example 1: Write an algorithm to determine a student’s final grade and


indicate whether it is passing or failing. The final grade is calculated as
the average of four marks.

Pseudocode:
◼ Input a set of 4 marks
◼ Calculate their average by summing and dividing by 4
◼ if average is below 50
Print “FAIL”
else
Print “PASS”
Detailed Algorithm
◼ Step 1: Input M1, M2, M3, M4
Step 2: GRADE  (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
Endif

21
3.2 Introduction to Flowchart

3.2.1 Concept of Flow chart


What is a flowchart?

• A flowchart is a picture (graphical representation) of the problem-


solving process.
• A flowchart gives a step-by-step procedure for solution of a problem.
Elements of a flowchart:

• Various geometrical shaped boxes represent the steps of the solution.


• The boxes are connected by directional arrows to show the flow of the
solution.
Uses of a flowchart:

• To specify the method of solving a problem.


• To plan the sequence of a computer program.
• Communicate ideas, solutions.
Guidelines for drawing a flow chart:

• Identify input and output.


• Apply reasoning skills to solve the problem.
• Draw the flowchart using the appropriate symbols and arrows to show
the Guidelines sequence of steps in solving the problem.
The most common flowchart types are:
• Process flowchart
• Swimlane Flowchart
• Workflow Diagram
• Data Flow Diagram
• EPC Diagram
• SDL Diagram
• Process Map
• Process Flow Diagram

22
Figure 3.1: Common Flowchart Symbols

Other Symbols Include:

23
3.2.2 Basic Structures of Flowchart
• Sequence Control Structure: This refers to line-by-line execution, in which
statements are executed sequentially, in the same order in which they appear
in the script. They might, for example, carry out a series of read or write
operations, arithmetic operations, or assignments to variables.

24
• Decision Control Structure: Depending on whether a condition is true or
false, the decision control structure may skip the execution of an entire block
of statements or even execute one block of statements instead of another.

• Loop Control Structure: This is a control structure that allows the execution
of a block of statements multiple times until a specified condition is met.

25
• A Select Case statement allows a variable to be tested for equality against a
list of values. Each value is called a case, and the variable being switched on
is checked for each select case.

◼ Example 2:
Flowchart of the above example of pseudocode

26
◼ Example 3:
Write an algorithm and draw a flowchart to convert the length in
feet to centimeter.
Pseudocode:

• Input the length in feet (Lft)


• Calculate the length in cm (Lcm) by multiplying LFT with
30
• Print length in cm (LCM)

◼ Example 4:
Write an algorithm that reads two values, determines the largest value
and prints the largest value with an identifying message.

ALGORITHM
Step 1: Input VALUE1, VALUE2
Step 2: if (VALUE1 > VALUE2) then
MAX  VALUE1
else
MAX  VALUE2
endif
Step 3: Print “The largest value is”, MAX

27
28
Chapter Four
4.0 Number System

A number system defines how a number can be represented using distinct


symbols. A number can be represented differently in different systems. For
example, the numbers (42)10, (2A)16 and (52)8 refer to the same quantity. Other
common number systems include base-16 (hexadecimal), base-8 (octal), and
base-2 (binary).

4.1 Base (Radix)

The base, or radix, of a number system tells you the number of symbols used in
that system. The base of any system is always expressed in decimal numbers.
The base, or radix, of the decimal system is 10. This means there are 10 symbols
0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 used in the system. A number system using two
symbols 0, and 1 would be base 2; eight symbols would be base 8; and so forth.
Remember to count the zero or the symbol used for zero when determining the
number of symbols used in a number system. The base of a number system is
indicated by a subscript (decimal number) following the value of the number.

4.1.1 Number System can be categorized in to two systems:

(a) Positional Number System


(b) Non-Positional Number System

a) Position Number System

In a positional number system, the position a symbol occupies in the


number determines the value it represents.
A positional (numeral) system is a system for representation of
numbers by an ordered set of numerals symbols (called digits) in
which the value of a numeral symbol depends on its position. For each
position, a unique symbol or a limited set of symbols is used. The
value of a symbol is given by the weight of its position expressed in
the bases (or radices) of the system. The resultant value of each
symbol is given by the value assigned to its position (e.g. by a product
of bases) and modified (e.g. multiplied) by the value of the symbol.
The total value of the represented number in a positional number is
then sum of the values assigned to the symbols of all positions.

29
Characteristics of Position Number System

• Uses a few symbols called digits


• These symbols represent different values depending on the position they
occupy in the number.

The value of each digit is determined by:


• The digit itself
• The position of the digit in the number
• The base of the number system
The base refers to the total number of digits in the number system. The
maximum values of a single digits are always equal to one less than the
value of the base.

Decimal (Base 10)


The first positional system we discuss is called the decimal system. The term decimal
is derived from the Latin root decem (meaning ten). The decimal system uses 10
symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) with the same face values as the symbols. The
place values in the decimal number system are powers of 10. Figure 1 shows the
place values and the symbol values in the integer 4782.

103 102 101 100 Place values


4 7 8 2 Symbols
4000 +700 +80 +2 Symbol Value

4782 Number
value
The decimal system uses 10 symbols in which the place values are powers of 10.

Binary to Decimal Conversion

Converting a number from binary to decimal is quite easy. All that is required is
to find the decimal value of each binary digit position containing a 1 and add
them up.
For example: convert 101012 to decimal
101012 = (1 x 24) + (0 x 23) + (1 x 22) + (0 x 21) + (1 x 20)
= 16 + 0 + 4 + 0 + 1
= 2110

Binary to Hexadecimal Conversion

To convert a binary number to hexadecimal, divide it into groups of four digits


starting with the rightmost digit. If the number of digits isn’t a multiple of 4,

30
prefix the number with 0’s so that each group contains 4 digits. For each four-
digit group, convert the 4-bit binary number into an equivalent hexadecimal
digit.

Example 1: Convert the binary number 10110101 to a hexadecimal


number

Divide into groups for 4 digits 1011 0101


Convert each group to hex digit B 5
B516

Example 2: Convert the binary number 0110101110001100 to


hexadecimal

Divide into groups of 4 digits 0110 1011 1000 1100


Convert each group to hex digit 6 B 8 C
6B8C16

Hexadecimal (Base 16)


The third positional system we discuss is called the hexadecimal system. The
term hexadecimal is derived from the Greek root hex (meaning 6) and the
Latin root decem (meaning ten). The hexadecimal system uses 16 symbols
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F). The face values of the first
ten symbols are the same as the symbols, but the face values of the symbols
A to F are 10 to 15 respectively. The place values in the hexadecimal number
system are powers of 16. Figure 3 shows the place values and the symbol
values in the hexadecimal system (A20E)16. Note that we use subscript 16 to
show that the number is in hexadecimal.

163 162 161 160 Place values


A 2 0 E Symbols
40,960 +512 +0 +14 Symbol Value
41,486 Number value in decimal
The hexadecimal system uses 16 symbols in which the place values are
powers of 16.

Characteristics of Hexadecimal Number System

• A position number system


• Has total of sixteen symbols or digits (0,1,2,3,4,5,6,7, 8, 9, A, B,
C, D, E, F). Hence its base =16

31
• The symbols A, B, C, D, E and F represents the decimal values 10,
11, 12, 13, 14, 15 respectively.
• The maximum value of a single digit is 15 (one less than the value
of the base.
• Each position of a digit represents a specific power of the base
(16).
• Since there are only 16 digits, 4 bits (24 = 16) are sufficient to
represent any hexadecimal number in binary.

Hexadecimal to Decimal Conversion


Converting a number from hexadecimal number to decimal is quite
easy. All that is required is to find the hexadecimal value of each
decimal number position and add them up.

For example: convert 1AF16 to decimal


1AF16 = (1 x 162) + (A x 161) + (F x 160)
= (1 x 256) + (10 x 16) + (F x 1)
= 256 +160 +15
= 43110

Hexadecimal to Binary conversion


To convert a hexadecimal number to a binary number, convert each
hexadecimal digit into a group of 4 binary digits.

Example: Convert the hex number 374F into binary


3 7 4 F
Convert the hex digits to binary 0011 0111 0100 1111
00110111010011112

Hex to Octal
Conversion of hex to octal is a two-step procedure. First, convert the
hex number to binary; and second, convert the binary number to octal.
Let’s convert the hexadecimal number ABC16 to octal:

A B C16
1010 1011 11002

101 010 111 1002


5 2 7 48

32
Octal (Base 8)
The word octal is derived from the Latin root octo (eight). Base b = 8, and
Eight symbols, S = {0, 1, 2, 3, 4, 5, 6, 7}. The place values in the octal
number system are powers of 8. Figure 4 shows the place values and the
symbol values of the octal (1256)8. Note that we use subscript 8 to show that
the number is an octal number.

83 82 81 80 Place values
1 2 5 6 Symbols
512 +128 +40 +6 Symbol Value
686 Number value in decimal
The octal system uses 8 symbols in which the place values are powers of 8.

Characteristics of Octal Number System


• A position number system
• Has total of eight symbols or digits (0,1,2,3,4,5,6,7).
• The maximum value of a single digit is 7 (one less than the value of the
base.
• Each position of a digit represents a specific power of the base (8).
• Since there are only 8 digits, 3 bits (23 =8) are sufficient to represent
any octal number in binary.

Conversion of octal number system to decimal


Conversion of octal numbers to decimal is best done by the positional
notation method. This process is the one we used to convert binary numbers
to decimal.

First, determine the decimal equivalent for each position by multiplying 8


by itself the number of times indicated by the exponent.
Example:
Convert 20578 = (2x 83) + (0x 82) + (5x 81) + (7x 80)
= 1024 + 0 + 40 +7
= 107110

Summary of the four positional number system


System Base Symbols Example
Binary 2 0,1 (1001.11)2
Octal 8 0,1,2,3,4,5,6,7 (156.23)8
Decimal 10 0,1,2,3,4,5,6,7,8,9 2345.56

33
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9, (A2C.A1)16
A,B,C,D,E,F

Binary Coded Decimal (BCD) Numbers


Another number system that is encountered occasionally is Binary Coded
Decimal. In this system, numbers are represented in a decimal form;
however, each decimal digit is encoded using a four-bit binary number.

For example: The decimal number 136 would be represented in BCD as


follows:
136 = 0001 0011 0110
1 3 6
Conversion of numbers between decimal and BCD is quite simple. To
convert from decimal to BCD, simply write down the four-bit binary pattern
for each decimal digit. To convert from BCD to decimal, divide the number
into groups of 4 bits and write down the corresponding decimal digit for each
4-bit group.

ASCII Character Encoding


The name ASCII is an acronym for: American Standard Code for
Information Interchange. It is a character encoding standard developed
several decades ago to provide a standard way for digital machines to encode
characters. The ASCII code provides a mechanism for encoding alphabetic
characters, numeric digits, and punctuation marks for use in representing text
and numbers written using the Roman alphabet.

b) Non-Positional Number System


In a non-positional number system, each number in each position does not
have to be positional itself. A non-positional number system still uses a
limited number of symbols in which each symbol has a value. However, the
position a symbol occupies in the number normally bears no relation to its
value the value of each symbol is fixed. To find the value of a number, we
add the value of all symbols present in the representation. For example, the
Egyptians use Hieroglyphics, and the Greeks use a numeral system. In this
system, we have symbols, such as I for 1, II for 2, III for 3, IV for 4 etc.
Roman numerals are a good example of a non-positional number system.
This number system has a set of symbols S = {I, V, X, L, C, D, and M}.

34
Characteristics
• Use symbols such as I for 1, II for 2, & III for 3 etc.
• Each symbol represents the same value regardless of its position in
the number
• The symbols are simply added to find out the value of a particular
number

Disadvantage
• It is difficult to perform arithmetic with such a number system

35
Chapter Five
5.0 Data Communication and Networking

Is the transfer of data/messages from one point to another point.

Basic Elements of Communication System

• Three basic elements of communication system are: -

- A sender (source) which creates the message to transmitted.


- A medium, which carries the message.
- A receiver (destination) which receives the message.

Data Transmission Modes

There are three ways or modes for transmitting data from one point to
another. These are simplex, half-duplex and full-duplex.

Simplex:

If transmission is simplex, communication can take place in only one


direction. For example, radio & T.V. etc.

Half-Duplex:

A half-duplex system can transmit data in both directions, but only in one
direction at a time. For example, wireless etc.

Full-Duplex:

A full-duplex system is used that allows information to flow simultaneously


in both directions on the transmission path. For example, telephone etc.

36
Transmission Media

• Wire Pairs: It is also known as twisted pair. Wire pairs are wires twisted
together to form a cable, which is thin insulated. Wire pairs are inexpensive.

Application: Telephone networks, within buildings & LAN etc.

Benefits & Drawbacks:

o Cheap
o Low data rate
o Short range
o Easy to work with

• Coaxial Cable: are groups of specially wrapped and insulated wire lines that
are able to transmit data at very high rates. These cables can transmit data
much faster than wire pairs.

Application: Long distance telephone transmission, Local Area


Networks etc.

Benefits:

o High transmission rate


o Higher noise immunity

Drawbacks:
o Comparatively costly
o Security problem

• Fiber Optics: Instead of using electricity to send data, fiber optics uses
light.
Application: Long haul trunks, Metropolitan trunks, LAN & WAN etc.

Benefits & Drawbacks:

o Greater capacity

37
o Smaller size & weight
o Lower attenuation

5.1 Network Topology

This is the arrangement of the elements of a communication network or the schematic


description of a network arrangement, connecting various nodes (Sender and
Receiver).
Kinds of Network Topology

• Physical topology: Is how the wires are run and the way in which a
network is laid out physically
• Logical topology is how the signal travels.

o A device can be wired to implement any logical


topology.
o LANs are logical busses or rings, depending on how
the hub is wired
o 4 basic types: mesh, star, bus, ring

o The most common physical topology is the star.


o All the wires come back to a central point
o May often see hybrid

Mesh Topology

• Every device has a dedicated point-to-point link to every other


device in network
• Mesh topology often used in MANs and WANs
• A fully connected mesh network has n(n-1)/2 physical channels
to link n devices, every device on the network must have n-1 I/O
ports

38
Advantage of Mesh Topology

• Privacy or security (every message travel along a dedicated line,


only the intended recipient sees it. Physical boundaries prevent
other user from gaining access the message
• Eliminating the traffic problems. The use of dedicated links
guarantees that each connection can carry its own data load; that
can occur when links must be shared by multiple devices.
• A mesh is robust. If one link becomes unusable, it does not
incapacitate the entire system.
• Fault identification and fault isolation easy. This enables the
network manager to discover the precise location of fault and
aids in finding its cause and solution.

Disadvantages of Mesh Topology

• Need more resource (cable & ports)


• Expensive to implement

Star Topology

• Each device has a dedicated point-to-point link only to a central


device (hub, switch, router)
• No direct traffic and link between devices

Advantages of star topology

• Easy to install and reconfigure and less expensive


• Each device need only one link and I/O port to connect it to any
other devices.)
• Robustness, if one link fails, only that link affected and other
links remain active.
• Identification and fault isolation

39
Disadvantages of star topology

• Failure of central device may cause network failure


• Requires more cable than (Ring, bus)

Bus Topology

• A multipoint topology
• Consists of cables connecting PCs or file servers
• Terminator attached to each end of bus cable segment
• to absorb signal and prevent signal reflection back on to covered
path
• Transmitting packet across bus
• Detected by all nodes on segment
• Given time limit to reach destination

Advantages of bus design

• Requires less cable than other topologies


• Easy to install and extend bus with a workstation

Disadvantages of bus topology

• Not secured
• Can become quickly congested with network traffic
• A fault in bus cable stops all transmissions even between devices
on the same side of the problem. The damaged area reflects
signals back the direction of origin, creating noise in both
directions
• It can difficult to add new devices (adding more require
modification of the

40
• backbone).

Ring Topology

• Each device is dedicated point-to-point connection only with the two


devices on either side of it
• Signal is passed from device to device until it reaches destination
• Each device functions as a repeater

Advantage

• Relatively easy to install and reconfigure


• Fault isolation is simplified

Disadvantage

• Unidirectional traffic
• A break in the ring can disable the entire network. This can be solved
by use dual ring

41
Networks Categories

Network category is determined by its size, ownership, the distance it cover


and its physical architecture

• Local Area Networks (LAN) - room, building


- A group of PCs that share a circuit.
- Backbone Networks (BN) - less than few kms
- A high-speed backbone linking together organizational LANs at
various locations.

• Metropolitan Area Networks (MAN) - (more than a few kms)


- connects LANs and BNs across different locations
- Often uses leased lines or other services used to transmit data.

• Wide Area Networks (WANs) - (far greater than 10 kms)


- Same as MAN except wider scale

42

You might also like