Introduction to Computers & Algorithms
Introduction to Computers & Algorithms
Why Computer?
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.
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?
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.
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.
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.
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.
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.
• 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.
• 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.
• 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:
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
• Highly Reliable
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.
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.
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.
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.
• 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.
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.
Unit Equivalent
1 kilobyte (KB) 1,024 bytes
1 megabyte (MB) 10 bytes or 103 KB
6
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?
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.
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.
• 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.
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.
Translators
• Assembler
• Compiler
• Interpreter
• Linker Loader
1. Assembler
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.
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.
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
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
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.
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.
Operating systems can be organized into four major types: real-time, single user/single- tasking, single-
user/multitasking, and multi- user/multitasking.
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.
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.
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.
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.
I. Network Types
Broadly computer network can be classified into different types such as LAN and WAN.
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.
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.
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.
• 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.
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)
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.
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
• Every step in an algorithm has its own logical sequence so it is easy to debug.
How To Write Algorithms:
START
1. a ← 0, b← 0, sum← 0
2. Read a, b
3. sum← a + b
4. Write “Sum is:”, sum
STOP
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
1. If statement:
Syntax or General Format of the IF Construct
STOP
2. IF-ELSE statement:
IF – ELSE Construct Syntax:
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
}
....
In
END-WHILE
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
}
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
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.
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