what is algorithm- Csmates.com

what is algorithm in software engineering

Algorithms and it's characteristics

An Algorithm is a sequence of computational steps that transform the input into the output. It is an important part of the program development process. The algorithm describes a specific computational procedure for achieving that input/output relationship. It is like a recipe that you can follow and solve problems.


  • An algorithm is said to be correct if, for every input instance, it halts with correct output.
  • We need a precise statement about the inputs, and the expected results for each input.
  • Their relationships should be proved, so that if the preconditions are satisfied, the post conditioned will be true.
  • If the program is large, it is broken into smaller modules. So the algorithms must be written such that the individual modules are independent and can be verified separately.

Running time

  • The method should be independent of the computers and the programming languages. 
  • Comparison of the two or more algorithms for the same problem can also be made based on the running time and count on the number of the instructions for each.
  • Running time depends on the input size and input itself.
  • In general, we want upper bound of time. T(n) = maximum time on any input of size n.
  • Sometimes, we look at "average case". T(n) = average time over all inputs of size n.
  • We never look at "best case".
  • Establish a lower bound on the number of operations needed to solve a problem. Best case is good only for showing "bad" lower bound for some input.

Space Usage

  • A program will require storage space for instructions, constants, and variables, for manipulating data, and for storing information to carry out computations.
  • It could also be a measure for algorithm computations/calculations.


  • The simplest and most straightforward way may not be the most efficient. However, simplicity makes verification and modification easier.

Algorithm Design Documentation tools:

Tools that are used for an algorithm design.
  • Flowcharts
  • Pseudocode

What are Flowcharts

Flowcharts are the tools used to describe or show the logical sequence and steps that occur in a process or decision-making situation. The process/art of developing flowcharting is called flowcharting.

Symbol for Flowcharts
Flowcharts are special shapes to represents different types of actions or steps in a process. 

Start or End
 The terminator symbol marks the starting or ending point of the system. It usually contains the word Start or End.

Action and Process
 A box can represent a single step or and entire sub-process within a larger process.


Document or Report
 A printed document or report is represented by the following.


A Decision or branching point is very important. Lines representing different decisions emerge from different points of the diamond.


Represents material or information entering or leaving the system, such as customer order (input) or a product (output).


Indicates that the flow continues on another page, where a matching symbol has been placed.


Lines indicates the sequence of steps and the direction of flow.

For ordering a Burger at a restaurant.

Nassi-Shneiderman Charts

Nassi Shneiderman charts are mean to assist in the design phase to determine and define the appropriate algorithms whereby the identified procedures can be realized. They were developed by Ike Nassi and Ben Shneiderman.

Nassi-Shneiderman charts are also referred to as program structure diagrams (PSD).

Nassi-Shneiderman diagrams illustrate algorithms and program functions as a flowchart. The main purpose of a Nassi-Shneiderman diagram is to create a logical structure for a program.

Nassi-Shneiderman notations

Process:- A process describes a program function as pseudocode. You can stack processes on top of each other to describe a sequence.
what is process

Parallel Process:- Place processes that are executed at the same time inside a trapezium created by drawing two diagonal lines in the upper and lower border of the table.

Loops:- Use loop notations when processes are repeated until a certain condition is met.

Decision:- The selection symbol is a rectangle divided into three parts by diagonal lines. Write the condition or decision in the uppermost triangle and place the two possible outcomes on either side of the decision. The two outcomes don't need to be the same size.

What are  Pseudocodes

Pseudocode is short, English phrase used to explain tasks within a program's algorithm. From this code, a flowchart or a higher-level language can be written. Pseudocode should not include keywords in a specific computer languages. Whereas, many write, "Pseudo-C" or "Pseudo-Pascal", this is not correct format. Indentation an be used to show grouping or logical order as well.

Essence of Pseudocode

The programming process is complicated. The program specifications are first understood and then a program is built about these specifications. In order to do this our thoughts must be organized. For non-trivial programs, each of the larger areas must be subdivided, and then those again divided, and so on. If we develop these habits for smaller, and easier programs, then the larger and non-trivial programs will appear easier to manage with organization. In short, pseudocode will save time in the long run. 

Writing Pseudocode.
  • First, make a list of the main tasks that must be accomplished on a piece of scratch paper.
  • Then, focus on each of those tasks.
  • Try to break each main task down into very small tasks that can each be explained with a short phrase.
  • There may eventually be a one-to-one co-relation between the lines of pseudocode and the lines of the code that we write after we have finished pseudocoding.
 Pseudocode Example
  • Write pseudocode for a program that obtains two integer numbers from the user and that prints out the sum of those numbers.
  • Prompt the user to enter the first integer.
  • Obtain user's first integer input.
  • Prompt the user to enter the second integer.
  • Obtain user's first second input.
  • Add first integer and second integer store the result in another variable.
  • Display an output prompt that explains the answer as the sum.
  • Display the result.

Post a comment