Algorithms and Programs

Algorithms and Programs example

Table of Contents

Algorithms and Programs

Both the algorithms and programs are used to solve problems, but they are not the same things in terms of their functionality. Step by step process to solve the problem is called an algorithm, and a program is a set of instructions that are given to the computer to solve the problems. 

The very basic example of an algorithm and program is shown in the following figure.

Problem: Find the sum of two numbers

Algorithms and Programs example

Differences Between Programs and Algorithms

The definitions of programs and algorithms are similar, but there are some key differences between them, which are explained under

Sr.

Algorithm

Program

1.        Domain knowledge helps to build the algorithm The programmer builds the program
2.        Platform (hardware and software) independent Platform (hardware and software) dependent
3.        It can be expressed in natural language, flow charts, pseudo code, and in a variety of languages. A compiler or interpreter translates a program into binary language that is understandable by any computer system.
4.        It is written using plain English and is easily understood without a programming background. It could be written in any programming language, such as C, C++, Python, or any other computer language.
5.        The constructions of an algorithm are designed based The construction of the program is implementation-based
6.        Generally, the algorithm is designed to solve the problem  A program can even contain no or many algorithms
7.        An algorithm can be executed by a person. A program is always executed by a computer.
8.        After the construction of the algorithm, the next step is to analyze it. After the construction of the Program, the next step is to test it.

Priori Analysis and Posteriori Testing

The time and space complexity of an algorithm can be calculated by using the following two methods

  • Priori Analysis
  • Posteriori Testing

The difference between A posteriori analysis and A Priori analysis is given below

Sr. Priori Analysis Posteriori Testing
1.       It is required for the Algorithm It is required for the program
2.       It is independent of language It is dependent on the language
3.       It is hardware-independent It is hardware-dependent
4.        It is done before the execution of an algorithm. It is done after the execution of an algorithm.
5.        It provides an approximate answer. It provides the exact answer.
6.        It is less expensive than Posteriori Analysis. It is more expensive than a priori analysis due to the need of software and hardware for execution.
7.        It uses the asymptotic notations to represent the time and space complexity of the algorithm It doesn’t use asymptotic notations to represent the time and space complexity of a program.
8.       Results are in the form of time and space complexity/function Results are in the form of watch time (Run time) and memory.
Share:

Leave a Reply

Your email address will not be published. Required fields are marked *

Share:

More Posts

Send Us A Message

Similar Posts