0% found this document useful (0 votes)
11 views48 pages

Introduction to Computers & Algorithms

Uploaded by

aditidandriyal07
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views48 pages

Introduction to Computers & Algorithms

Uploaded by

aditidandriyal07
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

UNIT-I

INTRODUCTION TO COMPUTERS & ALGORITHMS & FLOWCHARTS

Topics: Generation of computers, Computer system memory hierarchy, Input / Output,


RAM/ROM, Software & Hardware, Understand bit, byte, KB, MB, GB and their relations to
each other, Operating System overview, Computer Networks Overview.
Algorithms and Flow Charts – Examples of Flow charts for loops and conditional statements.
--8 Hrs

Why Computer?

• Increases the productivity and efficiency.


• Can crunch data at lighting speed.
• Can store vast amounts of information and reduce wastage of resources otherwise.
• Helps sort, organize, and search through information.
• Connects to the vast world of information through the Internet.
• Gets a better understanding of data.
• Allows to keep connected with each other.
• Can help in making a decision using the vast data.

Introduction to computers

• Computer is an electronic device that accepts input as data, processes it & stores temporarily
into a storage device and gives out useful output.

RAW DATA INFORMATION

COMPUTER

INPUT OUTPUT
PROCESSING
• A program is a sequence of instructions written using a computer programming language to
perform a specified task.
• Computers have power to perform billions of calculations in fraction of seconds. They are very
accurate and reliable.
Data?

• Data represents facts and figures.


• Examples:
Ram scored 99% marks.
Max. Temperature today at Dehradun was 25 degrees centigrade. Mumbai had a
rainfall of 220mm on 20th July 2020.
BSE : Sensex was trading at 40,000 points.
The above examples talk about facts and figures.
• The examples in the previous slide demonstrate that they are some facts but does not make much
sense.
• Now lets analyze the following:
– Ram scored 99% marks and stood first to the class.
– He was the highest scorer in the University.
– He secured a rank amongst the first 10 students in the state.

Characteristics of Computers:

• Speed
• Accuracy
• Automatic
• Diligence
• Memory
• No I.Q.
• Economical
• Versatile

Applications of Computers:

• Word Processing
• Internet
• Digital Audio or Video Composition
• Desktop Publishing
• e-Business
• Bioinformatics
• Health care
• GIS and Remote Sensing
• Meteorology
• Multimedia and Animation
• Legal System
• Retail Business

Generation of computers

Today’s computers originated in the second half of the twentieth century. As technology improved in
physics and electronics there was evolutionary developments in the hardware and software of computers.
Sooner the computer started to evolve, and the technological advancement marked a generation of
computers.

1. First Generation of Computers:


Computers were developed between 1940–1956 and were called the first-generation computers. They
were large and limited to basic calculations. They consisted of large devices like vacuum tubes. The input
method of these computers was a machine language known as the 1GL or the first-generation language.
The data was entered using physical methods such as punch cards, paper tape, and magnetic tape into
those computers.

Examples of the first-generation computers include ENIAC, EDVAC, UNIVAC, IBM-701, and IBM-650.
[Link] and [Link] invented the first successful electronic computer called ENIAC, that stands
for “Electronic Numeric Integrated and Calculator”.
These computers were large and very unreliable. They would heat up and frequently shut down and
could only be used for very basic computations.

Advantages:
1. They were made up of vacuum tubes which were the only electronic component available
during those days.
2. These computers could do calculations in milliseconds.

Disadvantages:
1. Heavy, Bulky, and very big in size, weighed about 30 tons.
2. These computers were very costly.
3. The vacuum tubes required a large cooling system.
4. Limited programming capabilities
5. Large amount of energy consumption.
6. Not reliable and frequent maintenance was required.
2 Second generation:

Second generation Computers were developed between 1957-1963. These computers were more reliable
and in place of vacuum tubes, they used transistors (semiconductors). Smaller in size compared to first
generation computers. The input for these computers was higher level languages like COBOL,
FORTRAN etc.
• Second generation computers were first to store instructions in memory, which moved from magnetic
drum to magnetic core technology.
• Second generation computers were first developed for the atomic energy industry.
• Examples of the second-generation computers include IBM 1620, IBM 7094, Honeywell 400, CDC
1604, CDC 3600, UNIVAC 1108. They were faster than their predecessors.

Advantages:
1. Due to the presence of transistors instead of vacuum tubes, the size of electronic components
decreased.
2. Less heating effect coz. energy consumed was less as compared to 1 st generation of computers.
3. Assembly language and punch cards were used as input.
4. Low cost than first generation computers.
5. Better speed, could calculate in microseconds.
6. Better portability as compared to first generation

Disadvantages:
1. A cooling system was required.
2. Constant maintenance was required.
3. Only used for specific purpose.
3 Third Generation of Computers:

Computers developed in the third generation period of 1964 – 1971 differed from the first and the second
generations by the fact that a new circuit element like IC’s (Integrated Circuits) were used. An integrated
circuit is a small device that can contain thousands and thousands of devices like transistors, resistors and
other circuit elements that make up a computer. Robert Noyce and Jack Kilby in 1958-1959 invented
Integrated Circuit or the IC chips. With the invention of IC’s, it became possible to fit thousands of
circuit elements
into a small region and hence the size of the computers eventually became smaller and smaller.
Computers that used IC’s during that period were, PDP-8 (Personal Data Processor), PDP-11, ICL 2900,
IBM 360 series, IBM 370/168, Honeywell-6000 series.

• These computers had few megabytes of main memory and magnetic disks which could store few
tens of megabytes of data per disk drive.
• High level programming languages like COBOL and FORTRAN were standardized by ANSI
• Some more high level programming languages like PL/I PASCAL and BASIC were introduced
at this time.
• Third generation computers were the first to implement time sharing operating systems.
• Input to these computers could now be provided using keyboards and mouse.

Advantages:

1. Faster than second generation computers and could perform 1 million transactions per second.
2. Smaller, cheaper and more reliable than their predecessors.
3. These computers had faster and larger primary memory and secondary storage.
4. Widely used for scientific as well as business applications.
5. During this generation of computers, standardization of existing high-level languages and invention
of new high-level languages was done.
6. Had time sharing operating system which allowed interactive use of computer by one or more
users simultaneously thereby improving the productivity of the users.

Disadvantages:
1. IC chips were difficult to maintain.
2. Highly sophisticated technology was required for the manufacturing of IC chips.
3. A cooling system was required.

4 Fourth Generation of Computers:

Fourth Generation of computers were developed between 1972 – 1989. These computers used VLSI
technology or the Very Large Scale Integrated (VLSI) circuits technology and were based on
microprocessor. Intel was the first company to develop a microprocessor. A microprocessor is used in a
computer for any logical and arithmetic operation and to perform execute any program.
Graphics User Interface (GUI)
technology used provided more comfort to users.
The first “personal computer” or PC developed by IBM, belonged to this generation. VLSI circuits had
almost about 5000 transistors on a very small chip and were capable of performing many high-level
tasks and computations. These computers were thus very compact and thereby required a small amount
of electricity to run.

Examples, STAR 1000, CRAY-X-MP (Supercomputer), DEC 10, PDP 11, CRAY-
This generation of computers had the first “supercomputers” that could perform many calculations
accurately.
They were also used in networking and used higher and more complicated languages as their inputs.
The computer languages like languages like C, C+, C++, DBASE etc. were the input for these
computers.

Advantages:
1. Fastest in computation and size was reduced as compared to the previous generation of
computer.
2. Heat generated was negligible.
3. Small in size as compared to previous generation computers.
4. Required less maintenance.
5. All types of high-level language could be used in these types of computers.

Disadvantages:
1. The Microprocessor design and fabrication were very complex.
2. Cooling system was required in many cases due to the presence of ICs.
3. Advance technology was required to make the ICs.
5 Fifth Generation of Computers:

This is the present generation of computers and is the most advanced one. The generation began around
1990 and is the present generation of computers. The methods of input include the modern high-level
languages like Python, R, C#, Java etc. The aim of the fifth generation is to make a device, which could
respond to natural language input and was capable of learning and self-organizing.
This generation is based on ULSI (Ultra Large Scale Integration) technology resulting in the production
of microprocessor chips having millions and billions of electronic components.
Examples include: Intel P4, i3 – i10, AMD Athlon, Desktop, Laptop, NoteBook etc.

Advantages:
1. They are most reliable and work faster.
2. They are available in different sizes and unique features.
3. They come with more user-friendly interfaces with multimedia features.

Disadvantages:
1. They tend to be sophisticated and complex tools.
2. They give more power to companies to watch what you are doing and even allow malicious
users to infect your computer.
3. They may make the human brain dull.

Computer System Memory Hierarchy

Memory Hierarchy Design is divided into two main types:

a) External Memory or Secondary Memory Comprising of Magnetic Disk, Optical Disk, Magnetic
Tape i.e. peripheral storage devices which are accessible by the processor via I/O Module.
b) Internal Memory or Primary Memory Comprising of Main Memory, Cache Memory & CPU
registers. This is directly accessible by the processor.

Fig. 1 Memory hierarchy


The following characteristics of Memory Hierarchy can be made from above Fig. 1:
i. Capacity: It is the total volume of information the memory can store. As we move from top to bottom
in the hierarchy, the capacity increases.
ii. Access Time: It is the time interval between the read/write request and the availability of the data. As
we move from bottom to top in the hierarchy, the access time decreases.
iii. Performance: Earlier computer system were designed without Memory Hierarchy, due to large
difference in access time the speed gap increased between the CPU registers and Main Memory, which
resulted in lower performance of the system and thus, enhancement was required. The performance of
the system increased by minimizing the levels of memory hierarchy to access & manipulate data.
iv. Cost per bit: As we move from bottom to top in the Hierarchy, the cost per bit
increases i.e. Internal Memory is costlier than External Memory.

Functional components of a Digital Computer

Von Neumann proposed design architecture for an electronic digital computer with the following basic
functional components as shown in Fig. 2.
• Input-Output unit
• Main Memory that stores data and instructions
• Processing unit contains arithmetic logical unit and processor registers
• Control unit that contains an instruction register and program counter
• Secondary device.

Fig. 2 Components of a Digital Computer

• Input Unit: The input unit consists of input devices that are attached to the computer. These
devices take input and convert it into binary language that the computer understands. Some of
the common input devices are keyboard, mouse, joystick, scanner etc.

• Central Processing Unit (CPU): Once the information is entered into the computer by the input
device, the processor processes it. The CPU is called the brain of the computer because it is the
control center of the computer. It first fetches instructions from memory and then interprets them
so as to know what is to be done. If required, data is fetched from memory or input device.
Thereafter CPU executes or performs the required computation and then either stores the output
temporarily in the memory or displays on the output device. The CPU has three main
components which are responsible for different functions – Arithmetic Logic Unit (ALU),
Control Unit (CU) and Memory registers.
• Arithmetic Logical Unit (ALU): The ALU, as its name suggests performs mathematical
calculations and takes logical decisions. Arithmetic calculations include addition, subtraction,
multiplication and division. Logical decisions involve comparison of two data items to see which
one is larger or smaller or equal.

• Control Unit: The Control unit coordinates and controls the data flow in and out of CPU and
also controls all the operations of ALU, memory registers and also input/output units. It is also
responsible for carrying out all the instructions stored in the program. It decodes the fetched
instruction, interprets it and sends control signals to input/output devices until the required
operation is done properly by ALU and memory.
• Memory Registers: A register is a temporary unit of memory in the CPU. These are used to
store the data that is directly used by the processor. Registers can be of different sizes(16 bit, 32
bit, 64 bit and so on) and each register inside the CPU has a specific function like storing data,
storing an instruction, storing address of a location in memory etc.
• Memory : Memory attached to the CPU is used for storage of data and instructions and is called
internal memory. The internal memory is divided into many storage locations, each of which can
store data or instructions. Each memory location is of the same size and has an address. With
the help of the
address, the computer can read any memory location easily without having to search the entire
memory. When a program is executed, it’s data is copied to the internal memory and is stored in
the memory till the end of the execution. The internal memory is also called the Primary memory
or Main memory. This memory is also called as RAM, i.e. Random Access Memory.
• Output Unit : The output unit consists of output devices that are attached with the computer. It
converts the binary data coming from CPU to human understandable form. The common output
devices are monitor, printer, plotter etc.

Computer Memories

• Computer memory is an internal storage area used to store data and programs.
• Computer memory can be categorized into two major types which can be used to
store data and programs.

1. Primary or Main memory

2. Secondary or Auxiliary memory

• While the main memory holds instructions and data when a program is executing, the auxiliary or the
secondary memory holds data and programs not currently in use and provides long-term storage.
• The primary memory is volatile, so the data can be retained in it, only when the power is on.
Moreover, it is very expensive and therefore limited in capacity.
• The secondary memory stores data or instructions permanently, even when the power is turned off. It
is cheap and can store large volumes of data. Moreover, data stored in auxiliary memory is highly
portable, as the users can easily move it from one computer to the other.
• The only drawback of secondary memory is that data can be accessed from it at a very slow speed as
and when compared with the data access speed of primary memory.
• A memory is just like a human brain. The memory is divided into large number of small parts called
cells. Each location or cell has a unique address.
For example, if the computer has 64k words, then this memory unit has 64 * 1024 =
65536 memory locations.
The address of these locations varies from 0 to 65535.

1. Primary or Main memory


• Primary memory holds only those data and instructions on which the computer is currently working.
• It stores instructions and data of a program in execution. It is volatile in nature, it can retain
content as long as power is ON. It is expensive and also limited in capacity as compared to
secondary memory i.e. it stores only the relevant data or instructions currently required for a
program or application.

• They are made up of semiconductors. Very fast compared to secondary memory but
slower than Internal CPU memory (Registers).

• Examples include RAM, ROM, etc and can vary in a size from 4 to 16 GB.
Characteristics of Main Memory:

▪ These are semiconductor memories.


▪ It is known as the main memory.
▪ A computer cannot run without the primary memory.
▪ Usually volatile memory.
▪ Data is lost in case power is switched off.
▪ It is the working memory of the computer.
▪ Faster than secondary memories.

RAM is of two types :−


• Static RAM (SRAM)
• Dynamic RAM (DRAM)
Static RAM (SRAM): Flip Flop (latch) is used to represent 1 and 0’s.

The word static indicates memory refresh is not required, it retains memory contents as long as
power is being supplied.
These are popular because of the following reasons:
• Simpler Design

• Faster and used as cache memory

• Highly Reliable

• Expensive and Long life


The Fig.3 illustrates a static ROM chip. They find applications in digital Cameras, high end mobile
phones.

Fig. 3 Static RAM

Dynamic RAM (DRAM):


It is made up of combinations of Capacitor and Transistor. The Capacitor gradually discharges and
must be continually refreshed in order to maintain the data. This is achieved by a refresh circuit that
rewrites the data several times per second. It is used as RAM as shown in Fig.4.

The following are the reasons it is preferred over static RAM:

• It is cheaper, smaller, higher capacity, forms major part of main memory.


• It has Short data lifetime
• Slower as compared to SRAM
• Smaller/Denser in size, Less expensive
• More power consumption
Fig. 4 DRAM

2. Secondary Memory or Auxiliary memory


It is used to store Data and programs that are not currently in use or not immediately required by the
program. It stores the information permanently as long as user desires and is not dependent on power
unlike primary memory. It’s Cheaper and can store very large quantity of data. Memory is organized
into a number of partitions called as cells just like housing colony. Each cell has a unique address that
can be used to identify and is used to store data permanently. The examples include Hardisk, Pen
Drives, CD-ROM, DVD, Magnetic Tapes etc.

Read Only Memory

ROM stands for Read Only Memory Data stored in ROM also known as firmware. Generally used in
PC to store instructions needed to Boot-up a computer. Non-volatile. Information is
programmed/stored permanently in such memories ROM extensively used in electronic items like
washing machine, Dishwasher, Cameras and microwave oven among others. Stores BIOS program
used in the Computer Booting Process.

Types of ROMs and their characteristics

a. MROM (Masked ROM)

These are Hard-wired devices that contain pre-programmed set of data or instructions
supplied by the manufacturers. These programs once written cannot be changed.
MROM are used in electronic devices like Washing machine, Smart TV’s, Microwave,
refrigerator etc.

b. PROM (Programmable Read Only Memory)

PROM can be modified only once by the user/manufacturer. It can be programmed only once and is
not erasable. They are used in devices such as cell phones, RFID tags, medical devices etc.

c. EPROM (Erasable and Programmable Read Only Memory)

EPROM can be erased by ultra-violet light. These can be modified by writing many a times by erasing
and writing the contents. These are used in smart memory, memory sticks etc.

d. EEPROM (Electrically Erasable and Programmable Read Only Memory)

• EEPROM is programmed and erased electrically. It can be erased and reprogrammed about ten
thousand times. Selective location can be modified and programmed. They can be erased one byte at
a time, rather than the entire chip. These find applications in flash memory, remote keyless systems,
microcontrollers etc.

Cache Memory
▪ Cache memory is a very high-speed semiconductor memory which can speed up the CPU.
▪ It acts as a buffer between the CPU and the main memory.
▪ It is used to hold those parts of data and program which are most frequently used by the CPU.
▪ The parts of data and programs are transferred from the disk to cache memory by the operating
system, from where the CPU can access them.
▪ Cache memory is basically a portion of memory made of high-speed static RAM (SRAM) instead of
the slower and cheaper dynamic RAM (DRAM) which is used for main memory.

It’s the special memory having speed of access time much faster than RAM and hence is suitable for
CPU to synchronize. It’s made of SRAM (Static RAM) and is smaller and
much expensive than RAM. It is placed between CPU and RAM, as shown in Fig. 5, which acts like a
buffer between CPU and RAM. CPU looks for Instructions and Data first in the Cache memory then
into RAM. The idea is to fetch most frequently accessed data and instructions so that they are
immediately made available to CPU.

Fig. 5 Cache Memory

Advantages of cache memory −


1. Cache memory is faster than main memory.
2. It consumes less access time as compared to main memory.
3. It stores the program that can be executed within a short period of time.
4. It stores data for temporary use.

Disadvantages −
1. Cache memory has limited capacity.
2. It is very expensive.
SEQUENTIAL AND RANDOM ACCESS:
Memory devices can be accessed either randomly or sequentially.

Computer - Memory Units


Memory unit is the amount of data that can be stored in the storage unit. This storage capacity is expressed
in terms of Bytes.
1. Bit (Binary Digit): A binary digit is logical 0 and 1 representing a passive or an active state of a
component in an electric circuit. A bit is a binary digit, the smallest unit of data on a computer. A bit can
hold only one of two values: 0 or 1, corresponding to the electrical values of off or on, respectively.
2. Nibble: A group of 4 bits is called nibble.
3. Byte: A group of 8 bits is called byte. A byte is the smallest unit, which can represent a data item or a
character.
4. Word: A computer word, like a byte, is a group of fixed number of bits processed as a unit. The length
of a computer word is called word-size or word length. It may be as small as 8 bits or may be as long as
96 bits.

Unit Equivalent
1 kilobyte (KB) 1,024 bytes
1 megabyte (MB) 10 bytes or 103 KB
6

1 gigabyte (GB) 109 bytes or 103 MB


1 terabyte (TB) 1012 bytes or 103 GB
1 petabyte (PB) 1015 bytes or 103 TB
1 exabyte (EB) 1018 bytes or 103 PB
1 zettabyte (ZB) 1021 bytes or 103 EB
1 yottabyte (YB) 1024 bytes or 103 ZB

Practice Problems:

Q 1: Karan has 600 MB of data. Kiran has 2000 MB of data. Will it all fit on Alice's 4 GB pen drive?
Sol:Yes it fits: 600 MB + 2000 MB is 2600 MB. 2600 MB is 2.6 GB, so it will fit on the 4 GB drive no
problem. Equivalently we could say that the 4 GB drive has space for 4000 MB.

Q2: Janahavi has 100 small images, each of which is 500 KB. How much space do they take up overall in
MB?

Sol: 100 times 500 KB is 50000 KB, which is 50 MB.

Q3: Assume a group is recording the sound inside a haunted House for 20 hours as MP3 audio files. About
how much data will that be, expressed in GB?
Sol: MP3 audio takes up about 1 MB per minute. 20 hours, 60 minutes/hour, 20 * 60 yields 1200 minutes. So
that's about 1200 MB, which is 1.2 GB.

Similarly, one 1 GB is 1,024 MB, or 1,073,741,824 (1024x1024x1024)


bytes. A terabyte (TB) is 1,024 GB; 1 TB is about the same amount of information as all of the books in a
large library. A petabyte (PB) is 1,024 TB. 1 PB of data, if written on a stack of CDs would create a stack
of height a mile high. An exabyte (EB) is 1,024 PB. A zettabyte (ZB) is 1,024 EB. Finally, a yottabyte
(YB) is 1,024 ZB.

Computer languages
• Programming language is a language specifically designed to express computations that can be
performed using the computer.
• These languages are used to create programs that are used to give the instructions.
• A programming language is a computer language that is used by programmers to communicate
with computers.
• Programs is a set of instructions that can be executed by a computer to perform a specific task.

Computer languages can be classified into three types:


• Machine Language
• Assembly Language
• High Level Language

1. Machine Level Language (MLL)

• Program is a set of instructions which are executed by the CPU using data to achieve an objective.
CPU fetches an instruction, decodes or figures it out and then executes the instruction.
• Instructions are written in terms of 1s and 0s only i.e in Binary meaning ON/OFF, where ON
represents 1 and 0 indicates OFF.
• These MLL differs from Computer to Computer based on hardware architecture. MLL is Fastest
in execution & Efficient Code can be written. Extremely difficult to write and can make mistakes.
MLL does not need a translator because it is already in the machine-readable form.

For example: To representation 80 in the computer system it is represented as


1010000. So, it is very difficult to learn. To overcome this problem the assembly language was
invented.

2. Assembly Level Language (ALL)

• Assembly language is easier to learn than Machine language.


• Assembly language uses mnemonics to represent data such as Mov, Add, Sub, End, etc.
• Assembly language is easy to understand and readable by human being as compared to
machine language.
• Modifications and error fixing can be done in assembly language.
• It is slower in execution as compared to machine language. For
example

Stop 0000

Start 0001

Error 1111

Add 1010

• It is easy to remember the assembly language because some alphabets and mnemonics are
used. Start, Stop, Error, Add are all examples of Mnemonics.

• System software Assembler is used to convert mnemonics into machine-


understandable form. It is the highly dependent on the machine architecture.

3. High level language


High level language uses English like language and is simpler to write a program compared to
Assembly or Machine language. It is programmer friendly language. Knowledge of Hardware is not
required. It is easy to understand and debug. It needs software like compiler or interpreter for
translation. It is used widely for programming
and is faster in development and completion of coding tasks. It is easy to maintain and is portable i.e.
can run or execute on any platform as it is independent of hardware architecture as shown in fig. 6.
Examples: FORTRAN, COBOL, C, C++, JAVA etc

Fig. 6 Relationship between HLL, ALL and MLL

Translators
• Assembler
• Compiler
• Interpreter
• Linker Loader

Computers understand only machine language. Support system software’s to accept a


program in high level language and help it execute on a given machine.

1. Assembler

System program that transforms code in Assembly language to Machine language


(object code)
Assembly Language Machine Language
MOV A, B 0010 1100 0011

2. Compiler
Translates a computer program written in a high level programming language to an executable code
for a target machine. i.e. Source Code to Assembly or Machine code.

High Level Language A=B

Assembly Language MOV A, B

Machine Language 0010 1100 0011

Examples of compilers: GNU or Turbo C Compiler

3. Interpreter
Reads a program in high level language and executes the instructions without having to compile the
program first. Takes a line of source code and executes that line. Then proceeds to do the same with the
subsequent line.
Examples: Python, PERL, BASIC languages

Compiler Interpreter
Translates the entire program into Converts one line of the source
machine code and then allows linking program and then executes
and loading for execution. that line.
Proceeds to the next
statement in this manner.

Compiled program runs faster Comparatively slower.

Produces complete error/warning Halts at the first error.


list
Compile once run many times Source code required each
time.

Ex: C, C++ JAVA, Python etc.

Linker and Loader


Linker
Linker is alternatively referred as binder, link editor. Assume, we write some code that
uses built in function POW to compute power (xy ie say some base X raise to expo n ent
) )
Y, the code for which already exists in the header file <math.h>.
Now, during compilation, Linker joins or patches your code with the externally available code of POW
in the libraries. Then it combines the output of a compiler or assembler to a single executable file.

Loader
Loader is program part of O.S that loads the executable program from the secondary memory into the
RAM (Main Memory) for the CPU to execute the code. It verifies memory permissions availability etc
and then hands over to the CPU the starting address for execution as shown in the fig. 7.

Fig. 7 Loader: Loads the programs combined by linker into main memory
Software & Hardware

A Computer is an electronic device that can perform various operations & calculations at a greater
speed than an ordinary machine or human mind.
• The computer hardware cannot think and make decisions on its own.
• The hardware needs a software (a set of programs) to instruct what has to be done.
• A program is a set of instructions that is arranged in a sequence to guide a computer to find a solution
for the given problem.
• The process of writing a program is called programming.

It comprises of many physical and tangible components that we can touch or feel, called the Hardware
and programs and commands that drive the hardware, called the Software.

The Software is the set of instructions fed in form of programs to manage the computer system and control
the hardware components. For example:
• The antivirus that protects our computer system is a type of Software.
• The media players that we use to play multimedia files such as movies, music etc. are Software.
• The Microsoft Office we use to edit the documents is Software.

Depending on its function and application, Software can be divided into three major types:
a. System Software and application software

System Software application


software
It is a collection of programs that enable the It is a collection of programs written for a
users to interact with hardware components specific application. Like, we have library
efficiently system, inventory control system, etc
It controls and manages the hardware It uses the services provided by the
system software to interact with hardware
components

System software is machine dependant It is machine independent

The programmer must understand the The programmer ignores the architecture
architecture of the machine and hardware of the machine and hardware details to
details to write a system software write an application software

Interacts with the hardware directly Interacts with the hardware indirectly
through system calls provided by system
software

Writing a system software is a Writing application programs is


complicated task relatively very easy

Example: compiler, operating system Example: MS-WORD, PAINT


a. System Software

These are the software that directly allows the user to interact with the hardware components of a
computer system. As the humans and machines follow different languages, there has to be an interface
that will allow the users to interact with the core system, this interface is provided by the software. The
system software is the most important part of the a computer system that controls the hardware. This
System Software can be further divided into four major types:

i. The Operating System – It is the main program that manages and controls the inter-action of
the components of a computer system. For ex., Microsoft Windows, Linux, Mac OS etc. are
vendors who supply the Operating System ( OS ).
ii. The Language Processor – The hardware components present in the computer system does not
understand human language. There are three types of languages involved in the world of human-
machine interaction:
• Machine-Level Language: The machines only understand the digital signals or the binary
codes or the binary language which consist of 0’s and 1’s. These are totally machine
dependent language.
• Assembly-Level Language: These are the Low-Level Languages (LLL), that forms a
correspondence between machine level instruction and general assembly level
instructions. Assembly language uses a mnemonics to represent each low-level machine
instruction or operation-code also called the op-codes. For ex. ADD instruction is used to
add two quantities, the HALT instruction is used to stop a program etc. It is a machine
dependent language and varies from processor to processor.
• High-Level Language: These are the simple English like statements, that humans use to
program and code as it is easy to read and understand by the humans. For ex., Java, C,
C++, Python etc.
The machine level language is very complex to understand and code, therefore the users prefer
the High-Level Language or the HLL for coding. These codes need to be converted into the
machine language so that the computer can easily understand and work accordingly. This
operation is performed by the Language Processor which is made up of further three
components:
• Assembler: Language processor used to convert the assembly language into machine
level language.
• Compiler: Language processor used to convert High-Level Language into machine level
language at once, thus execution time is fast. The error detection is difficult in a compiler.
Programming Languages like C, C++ and Simula use compilers.
• Interpreter: Language processor used to convert High-Level Language into machine level
language line-by-line, thus execution time is slow. Error- detection is easier in an
interpreter as it reports as soon as a bug (error) is caught and restarts the process.
Programming Languages like Python, Ruby, Visual Basic and Java uses an interpreter.
iii. The Device Drivers – The device drivers are the system software programs that act as an
interface between the various Input-Output devices and the users or the operating system. For
ex., the Printers, CD-ROM, DVD, Web cameras come with a driver disk that is needed to be
installed into the system to make the device run in the system.
iv. The BIOS – It stands for Basic Input Output System and is a small firmware that controls input-
output devices attached to the system. This software is also responsible for starting the OS or
initiating the booting process.

Operating System overview

An operating system (OS) is a system software program that controls the system's hardware and that interacts
with the user and application software. OS is the computer's master control program. It provides the tools
(commands) that enable users to interact with the PC. When a command is entered, the OS translates it
into code that the machine can understand. OS also ensures that the results are displayed on screen,
printed, and so on.

The primary goal of an operating system is to make the computer system convenient and efficient to use.
An operating system ensures that the system resources (such as CPU, memory, I/O devices, etc) are utilized
efficiently.

For example, there may be many service requests on a web server and each user request need to be
serviced. Similarly, there may be many programs residing in the
main memory.
Therefore, the system needs to determine which programs are active and which need to
wait for some I/O operation.

The Operating System performs the following functions:


• Displays the on-screen elements with which user can interact.
• Loads programs (such as word processing and spreadsheet
programs)
into the computer’s memory to be used by the user.
• Coordinates programs working with the computer's hardware and other software.
• Manages the way information is stored on and retrieved from disks.

Operating systems can be organized into four major types: real-time, single user/single- tasking, single-
user/multitasking, and multi- user/multitasking.

I. Real-time operating system ( RTOS ):

A RTOS is a very fast, relatively small OS. Real-time OS are often the embedded OS, they are built into
the circuitry of a device and are not loaded from a disk drive. A real-time operating system is needed to
run real-time applications and they responds to certain inputs extremely quickly—thousandths or
millionths of a second (milliseconds or microseconds, respectively). Real-time applications are needed
to run medical diagnostics equipment, life-support systems, machinery, scientific instruments, and
industrial systems.
RTOS is used in the following make of mobiles:
• Symbian - Used in cell phones, mainly ones made by Nokia.
• Embedded Linux - Android is a subset, used in many devices like Samsung etc.
• BlackBerry OS - For BlackBerry phones.
• iOS - Subset of Mac OS X, used in Apple's mobile devices.

II. Single-User/Single-Tasking Operating Systems

An operating system that allows a single user to perform just one task at a time is a single-user/single
tasking operating system. To a user, a "task" is a function such as printing a document, writing a file to
disk, editing a file, or downloading a file from a network server. To the operating system, a task is a
process, and small and simple OS can only manage a single task at a time. MS-DOS is one example of a
single-tasking OS, and the Palm OS, used on the Palm handheld computers. Such operating systems are
limited in characteristic and they take up very little space on disk or in memory while running and do
not require a powerful and expensive computer.

III. Single-User/Multitasking Operating Systems

A single-user/multitasking operating system allows a single user to perform two or more functions at
once. It takes a special operating system to keep two or more tasks running at once. The most
commonly used personal computers usually run such OS, including Microsoft Windows and the
Macintosh Operating System. The multitasking features of these OS have greatly increased the
productivity of people in a large variety of jobs because they can accomplish more in a shorter period of
time.
A disadvantage of a single-user/multitasking operating system is the increased size and complexity it
needs to support multitasking.

IV. Multi-User/Multitasking Operating Systems

A multi-user/multitasking operating system is an operating system that allows multiple users to use
programs that are simultaneously running on a single network server; called a terminal server as shown
in Fig. 8. This is not at all the same as connecting to a network server for the sake of accessing files and
printers. In multi-user OS, it gives each user a complete environment, called a user session, on the
server. Each user’s applications
run within their user session on the server separate from all other user sessions. The software that makes
this possible is called a terminal client. In a multi-user/multitasking operating system environment, all
or most of the processing occurs at the server. Examples of multi-user OS include UNIX, VMS (Virtual
Memory System) used in older mid-range computers by Digital Equipment Corporation (DEC), and
mainframe operating systems such as MVS (Multiple Virtual Storage) used in IBM Mainframe
System/370 and System/390.

Fig. 8 Multi user/multi tasking operating each user runs his/her own session on the
server

The advantage of these operating systems is that they can be managed by making changes to one server,
rather than to many terminal clients. They also allow the user to work with applications that require a
more powerful
computer. A disadvantage is that if the server goes down, then the user work is disrupted.

1. The small pictures on the desktop are called icons that represent links to resources on the PC or
network.
2. Multi-tasking is the ability to perform two or more tasks at the same time.
3. You interact with a command-line interface by typing strings of characters at
Command Prompt .
4. A running program may take up the whole screen or it may appear in a rectangular frame, called
Window
5. A program that lets you back up data files is an example of
Utility Program.
6. In a graphical user interface, you use a mouse (or other pointing device) to move a screen by
dragging around the screen.
7. A Operating System supports an application that responds to certain input very, very quickly.
8. The process of moving from one open window to another is called
switching
9. In Windows, when you right-click some objects on the screen, a special
menu appears.
10. In a GUI scrolling buttons let you view parts of a program or file that do not fit in the window.

Computer Networks

A computer network is a system in which multiple computers are connected to each other to share
information and resources. Connectivity may be established by the means of Physical cables, Optical
wires or Wireless technologies. An example of computer network is shown in fig. 9. Communication
between devices/computers also called nodes takes places by the means of established rules called as
Protocols. Nodes may be Computers, Printers, Scanners, Servers etc. Resource on a computer
network may be any device such as printers, scanners, modem or sharing software. Example of
Resource sharing may be a high-speed printer.
Devices in a computer network are identified by a name and a unique address called a host address (IP
Address) that helps in identifying and locating the device on a network.

Fig. 9 Typical Computer Network Connectivity Advantages of


Comp. Networks
▪ File Sharing
▪ Resource Sharing
▪ Increased Storage Capacity
▪ Load Sharing
▪ Facilitate communications

I. Network Types
Broadly computer network can be classified into different types such as LAN and WAN.

a. Local Area Networks (LANs)


A local area network (LAN) is a data communication system consisting of several devices such as
computers and printers. This type of network contains computers that are relatively near each other and
are physically connected using cables, infrared links, or wireless media. A LAN can consist of just two
or three PCs connected together to share
resources, or it can include hundreds of computers of different kinds. Any network that exists within a
single building, or even a group of adjacent buildings, is considered a LAN.

A LAN is not a system that connects to the public environment (such as the Internet) using phone or
data lines. It is often helpful to connect separate LANs together so they can communicate and exchange
data. In a large company, for example, two departments located on the same floor of a building may
have their own separate LANs, but if the departments need to share data, then they can create a link
between the two LANs.

b. Wide Area Networks (WANs)


Typically, a wide area network (WAN) is two or more LANs connected together, generally across a
wide geographical area separated by thousands of kilometers. For example, a company may have its
corporate headquarters and manufacturing plant in one city and its marketing of office in another. Each
site needs resources, data, and programs locally, but it also needs to share data with the other sites. To
accomplish this feat of data communication, the company can attach devices that connect over public
utilities to create a WAN. (Note, however, that a WAN does not have to include any LAN systems. For
example, two distant mainframe computers can communicate through a WAN, even though neither is
part of a local area network.)
These remote LANs are connected through a telecommunication network (a phone company) or via the
Internet through an Internet service provider (ISP) that contracts with the telecommunication networks
to gain access to the Internet’s backbone.

II. Hybrid Networks

Between the LAN and WAN structures, you will find hybrid networks such as campus area networks
(CANs) and metropolitan area networks (MANs). In addition, a new form of network type is emerging
called home area networks (HANs). The following section explains these networks.
a. Campus Area Networks (CANs)
A campus area network (CAN) follows the same principles as a local area network, only on a larger and
more diversified scale. With a CAN, different campus offices and organizations can be linked together.
For example, in a typical university setting, a bursar's office might be linked to a registrar's office. In
this manner once a student has paid his or her tuition fees to the bursar, this information is transmitted
to the registrar's system so the student can enroll for classes. Some university departments or
organizations might be linked to the CAN even though they already have their own separate LANs.

b. Metropolitan Area Networks (MANs)


The metropolitan area network (MAN) are large-scale networks that connects multiple corporate LANs
together. MANs usually are not owned by a single organization; their communication devices and
equipment are usually maintained by a group or single network provider that sells its networking
services to corporate customers. MANs often take the role of a high-speed network that allows for the
sharing of regional resources.

c. Home Area Networks (HANs)


A home area network (HAN) is a network contained within a user’s home that connects a person’s
digital devices, from multiple computers and their peripheral devices, such as a printer to telephones,
VCRs, DVDs, televisions, video games, home security systems, “smart” appliances, fax machines, and
other digital devices that are wired into the network.

III. Intranets and Extranets

The need to access corporate Web sites has created two classifications known as intranets and extranets.

Much of the technology available on the Internet is also available for private network use. The
company’s internal version of the Internet is called an intranet. An intranet uses the same Web server
software that
gives the public access to Web sites over the Internet. The major difference is that an intranet usually
limits access to employees and selected contractors having ongoing business with the company. Web
pages have become very popular and, using integrated software, many operating systems offer
complete Web server software or at least a personal Web server. This gives users the ability to create
Web pages on their local computers that can be viewed by other members of the same network. Just,
like on the Internet, users can allow others (again, usually employees) to browse their Web site and to
upload or download files, video clips, audio clips, and other such media. Users also can set controls and
limit who may access the Web site. Extranets are becoming a popular method for employees to
exchange information using the company’s Web site or e-mail while traveling or working from home.

An extranet is a partially accessible internal company Web site for authorized users physically located
outside the organization. Whereas an intranet resides completely within the company's internal network
and is accessible only to people that are members of the same company or organization, an extranet
provides various levels of accessibility to outsiders. You can access an extranet only if you have a valid
username and password, and your identity determines which parts of the extranet you can view.

Algorithms:
• An algorithm is a sequence of steps to solve a particular problem or algorithm is an ordered set
of unambiguous steps that produces a result and terminates in a finite time.
OR
• Algorithm may be defined as a finite and ordered sequence of steps which when performed
leads to the solution of a problem in a definite amount of time.

• A well-defined algorithm always provides an answer and is guaranteed to terminate.


• Algorithms are mainly used to achieve software re-use.

A good algorithm must have the following characteristics:

• Be precise
• Be unambiguous
• Not even a single instruction must be repeated infinitely
• After the algorithm gets terminated, the desired result must be obtained.
How/Why Algorithms?

Algorithms are usually written in combination of our spoken language and one or more programming
languages, in advance of writing a program.

• Independent of Computer Languages


• Easily converted into Programs
• Step by Step Process Assists in error correction
• English and Math like

Algorithms vs. Programs


Both are sets of instructions on how solve a problem Algorithms
• In plain language understandable to People
Programs:
• Converting Algorithms into Instructions usually in a HLL understandable a
computer(compiler).

Algorithms Terminology

1. Arithmetic Operators
+ - * / Mod or %

2. Relationship Operators
> < >= <= = !=

3. Input/output
• Input, Read, Get, Scan (for taking Input)
• Output, Write, Show, Display, Print (for displaying result)

4. Constant vs. Variable


PI <- 3.142 (Constant)
Area <- PI * Radius * Radius (Variable)

5. Assignment vs. Equality


← Assignment Operator
= Equality (Comparison)
Say A is 10 and B is 20
A←B (Assignment operator: used to assign value to a variable) Is (A =
B) (Equality operator used to compare two variables)

NOTE: WAA abbreviation for Write an Algorithm

The algorithm and flowchart include following three types of control structures:

1. Sequence: In the sequence structure, statements are placed one after the other and the execution
takes place starting from up to down.

2. Branching (Selection): In branch control, there is a condition and according to a condition, a


decision of either TRUE or FALSE is achieved. In the case of TRUE, one of the two branches is
explored; but in the case of FALSE condition, the other alternative is taken.

3. Loop (Repetition): The Loop or Repetition allows a statement(s) to be executed repeatedly based
on certain loop condition e.g. WHILE, FOR loops.

Advantages of algorithm

• It is a stepwise representation of a solution to a given problem, which makes it easy to understand.

• An algorithm uses a definite procedure.

• It is not dependent on any programming language, so it is easy to understand for


anyone even without programming knowledge.

• Every step in an algorithm has its own logical sequence so it is easy to debug.
How To Write Algorithms:

Step 1: Define your algorithms input


Step 2: Define the variables
Step 3: Outline the algorithm's operations
Step 4: Output the results of your algorithm's operations
Algorithms based on Sequence:
Sequence means that each step of the algorithm is executed in the specified order.

Q: WAA to find the Sum of Two Numbers

START
1. a ← 0, b← 0, sum← 0
2. Read a, b
3. sum← a + b
4. Write “Sum is:”, sum
STOP

Q: WAA to Exchange Two Numbers using third variable

START
1. a ←0, b←0, temp←0
2. Read a, b
3. temp← a
a← b
b← temp
4. Write “After Exchange a is”, a
5. Write “After Exchange b is”, b
STOP

Algorithms based on Decision Making- Control Flow


Decision statements are used when the outcome of the process depends on some condition. For
example, if x=y, then print “EQUAL”. Hence, the general form of the if construct can be given as if
condition then process.

1. If statement:
Syntax or General Format of the IF Construct

IF (CONDITION IS TRUE) THEN


{
Statement 1
Statement 2
.......
Statement N
}

Q: WAA to ONLY print a message if GUESS number is 100


START
1. num← 0
2. Read num
3. IF (num = 100) THEN
{
Print “You have Guessed the lucky Number” Print
“Congratulations !!!”
}

STOP

2. IF-ELSE statement:
IF – ELSE Construct Syntax:

IF (CONDITION_1 IS TRUE) THEN


{
Statement 1
Statement 2
.......
Statement N
}
ELSE
{
Statement A Statement
B
.......
Statement Z
}

Q: WAA to find if number is ODD or EVENSTART


1. num← 0
2. Read num
3. IF (num%2 = 0) THEN
{
Print “Number is Even”
}
ELSE
STOP
{
Print “Number is Odd”
}

Q: WAA to calculate area ONLY of a valid Triangle using Herons Formula.

START
1. a←0, b←0, c←0, s←0, area←0
2. Read a, b, c
3. IF ( (a + b) > c AND (b + c) > a AND (a + c) > b) THEN
{
s← (a + b + c)/2
area ← SQRT(s*(s-a)*(s-b)*(s-c))
Write “Area is:”, area
}
ELSE
{
Write ”Invalid Triangle”
}
STOP

3. IF-ELSEIF-ELSE
statement:
Syntax:
IF (Condition_A is TRUE) THEN
{
Statement 1
Statement 2
.......
Statement n
}
ELSE IF (Condition_B is TRUE) THEN
{
Sa
Sb
.......
Sn
}
ELE
{
Na
Nb
........
Nn
}

Q: WAA to find a number is Positive, Negative or Zero START


1. num← 0
2. Read num
3. IF (num = 0) THEN
{
Print “Number is ZERO”
}
ELSE IF (num < 0) THEN
{
Print “Number is Negative”
}
ELSE
{
Print “Number is Positive”
}STOP

Algorithms based on Repetition


Repetition, which involves executing one or more steps for a number of times, can be implemented
using constructs such as while, do-while, and for loops. These loops execute one or more steps until
some condition is true.
1. while loop:
Syntax:
WHILE (CONDITION_TRUE) DO
Ia
Ib

....
In
END-WHILE

Q: WAA to display Numbers from 1 to N START


1. num 1, N
2. Read N
3. WHILE (num <= N) DO
Print num
num← num + 1
END-WHILE
STOP

2. Repeat...for Count
Syntax of the Repeat...for Count

// Count Up
REPEAT for count 1, 2, 3,...N, step +1
{
Sa
Sb
...
Sn
}
OR
// Count Down
REPEAT for count N, N-1, N-2,...0
{
Sa
Sb
...
Sn
}

Q: WAA to find the factorial of a number.

START
Step 1: n←0, fact←1
Step 2: Read N
Step 3: for i=1 to N, step 1
{
fact←fact*i
}
Step 4: Print fact
STOP
Q: WAA to generate the Fibonacci Series 0,1,1,2,3,5,8..N. For N >= 1

START
1. a← 0, b← 1, next ← 0, N←0
2. Read N
3. Print a, b
4. WHILE (next <= N-2) DO
next ← a + b
Print next
a=b
b=next
END-WHILE
STOP
Flowcharts

• “Flowchart is diagrammatic /graphical representation of sequence of steps to solve a


problem.”
Flowchart is a graphical or symbolic representation of a process.
• It is basically used to design and document virtually complex processes to help the viewers to visualize
the logic of the process, so that they can gain a better understanding of the process.
• When designing a flowchart, each step in the process is depicted by a different symbol and is associated
with a short description. The symbols in the flowchart are linked together with arrows to show the flow
of logic in the process

Advantages of flowchart:
• Flowchart is an excellent way of communicating the logic of a program.
• Easy and efficient to analyze problem using flowchart.
• During program development cycle, the flowchart plays the role of a blueprint, which makes program
development process easier.
• After successful development of a program, it needs continuous timely maintenance during the course
of its operation. The flowchart makes program or system maintenance easier.
• It is easy to convert the flowchart into any programming language code.

To draw a flowchart following standard symbols are use:-


Q: Draw a flowchart to add two numbers.

START

Read n1, n2

Sum←n1+n2

Print Sum

STOP
Q: Draw a flowchart to find area of a circle.

START

Read radius

Area←3.14*radius*radius

Print Area

STOP
Q: Draw a flowchart to swap two numbers.

START

Read a, b

temp ←a
a←b
b ← temp

Print a, b

STOP
Q: Draw a flowchart to find the smallest of two numbers.

START

Read a,b

small←a

Yes
b<small
small←b
?

NO

Print small

STOP
Q. Draw a flowchart to print numbers from 1 to 100.

START

i=1

Is NO
(i<=100)?

Yes

Print i

i=i+1

STOP

You might also like