[go: up one dir, main page]

0% found this document useful (0 votes)
17 views5 pages

Algo

An algorithm is a step-by-step procedure for solving a problem, characterized by clarity, defined inputs and outputs, finiteness, feasibility, and independence from programming languages. Flowcharts visually represent the sequence of logical steps in a program, adhering to specific design principles. Additionally, software components like compilers, interpreters, assemblers, linkers, and loaders facilitate the translation of high-level programming languages into machine code for execution by hardware.

Uploaded by

Nipun Gupta
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)
17 views5 pages

Algo

An algorithm is a step-by-step procedure for solving a problem, characterized by clarity, defined inputs and outputs, finiteness, feasibility, and independence from programming languages. Flowcharts visually represent the sequence of logical steps in a program, adhering to specific design principles. Additionally, software components like compilers, interpreters, assemblers, linkers, and loaders facilitate the translation of high-level programming languages into machine code for execution by hardware.

Uploaded by

Nipun Gupta
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
You are on page 1/ 5

ALGORITHM: - Algorithm is a step-by-step procedure, which defines a set of instructions to

be executed in a certain order to get the desired output. Algorithms are generally created
independent of underlying languages, i.e., an algorithm can be implemented in more than one
programming language.

Characteristics of an Algorithm
Not all procedures can be called an algorithm. An algorithm should have the following
characteristics −

• Unambiguous − Algorithm should be clear and unambiguous. Each of its steps and
their inputs/outputs should be clear and must lead to only one meaning.
• Input − An algorithm should have 0 or more well-defined inputs.
• Output − An algorithm should have 1 or more well-defined outputs, and should
match the desired output.
• Finiteness − Algorithms must terminate after a finite number of steps.
• Feasibility − Should be feasible with the available resources.
• Independent − An algorithm should have step-by-step directions, which should be
independent of any programming code.

How to Write an Algorithm?


There are no well-defined standards for writing algorithms. Rather, it is problem and resource
dependent. Algorithms are never written to support a particular programming code.

As we know that all programming languages share basic code constructs like loops (do, for,
while), flow-control (if-else), etc. These common constructs can be used to write an algorithm.

We write algorithms in a step-by-step manner, but it is not always the case. Algorithm
writing is a process and is executed after the problem domain is well-defined. That is, we
should know the problem domain, for which we are designing a solution.

Example

Let’s try to learn algorithm-writing by using an example.

Problem − Design an algorithm to add two numbers and display the result.

Step 1 − START

Step 2 − declare three integers a, b & c Step 3 −

define values of a & b

Step 4 − add values of a & b

Step 5 − store output of step 4 to c Step 6 −

print c

Step 7 − STOP
Flowchart: - is a diagrammatic representation of sequence of logical steps of a program.
Flowcharts use simple geometric shapes to depict processes and arrows to show relationships
and process/data flow.

These are some points to keep in mind while developing a flowchart −

• Flowchart can have only one start and one stop symbol
• On-page connectors are referenced using numbers
• Off-page connectors are referenced using alphabets
• General flow of processes is top to bottom or left to right
• Arrows should not cross each other
Example Flowcharts

1) Here is a flowchart to calculate the average of two numbers.

2) Display the greatest number among two numbers.


Concept of assembler, compiler, interpreter, loader and linker.
Computers are a balanced mix of software and hardware. Hardware is just a piece of mechanical
device and its functions are being controlled by a compatible software. Hardware understands
instructions in the form of electronic charge, which is the counterpart of binary language in
software programming. Binary language has only two alphabets, 0 and 1. To instruct, the
hardware codes must be written in binary format, which is simply a series of 1s and 0s. It would
be a difficult and cumbersome task for computer programmers to write such codes, which is why
we have compilers to write such codes.

Computer system is made of hardware and software. The hardware understands a language;
which humans cannot understand. So we write programs in high-level language, which is easier
for us to understand and remember. These programs are then fed into a series of tools and OS
components to get the desired code that can be used by the machine.

Compiler
The high-level language is converted into binary language in various phases. A Compiler is a
software that takes typically takes a high-level language (Like C and C++) code as input and
converts the input to a low-level language at once. It lists all the errors if the input code does not
follow the rules of its language. This process is much faster than interpreter but it becomes difficult
to debug all the errors together in a program. A compiler is a translating program that translates the
instructions of high-level language to machine level language. A program which is input to the
compiler is called a Source program. This program is now converted to a machine level language
by a compiler is known as the Object code.

Interpreter

An interpreter, like a compiler, translates high-level language into low-level machine language.
The difference lies in the way they read the source code or input. A compiler reads the whole
source code at once, creates tokens, checks semantics, generates intermediate code, executes the
whole program and may involve many passes. In contrast, an interpreter reads a statement from
the input, converts it to an intermediate code, executes it, then takes the next statement in
sequence. If an error occurs, an interpreter stops execution and reports it. whereas a compiler
reads the whole program even if it encounters several errors.
Assembler
An assembler translates assembly language programs into machine code. The output of an
assembler is called an object file, which contains a combination of machine instructions as well as
the data required to place these instructions in memory.

Linker
Linker is a computer program that links and merges various object files together in order to make
an executable file. All these files might have been compiled by separate assemblers. The major
task of a linker is to search and locate referenced module/routines in a program and to determine
the memory location where these codes will be loaded, making the program instruction to have
absolute references.

Loader
The loader is special program that takes input of object code from linker, loads it to main
memory, and prepares this code for execution by computer. Loader allocates memory space to
program. Even it settles down symbolic reference between objects. It in charge of loading
programs and libraries in operating system. The embedded computer systems don’t have loaders.
In them, code is executed through ROM. Loader is a part of operating system and is responsible
for loading executable files into memory and execute them. It calculates the size of a program
(instructions and data) and creates memory space for it. It initializes various registers to initiate
execution.

You might also like